/**      
*  @Title:  SystemServiceImpl.java  
*  @Package  com.zjdiepu.www.biz.zpp  
*    
*  @author  zhangpp
*  @date  2017年9月8日  上午11:45:22  
*  @version  V1.0      
*/
package com.zjdiepu.www.biz.zpp;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.jpush.api.JPushClient;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.PushPayload;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zjdiepu.www.base.core.AbstractSysUser;
import com.zjdiepu.www.base.core.BaseException;
import com.zjdiepu.www.base.enums.status.DpStatus;
import com.zjdiepu.www.base.enums.status.MessageStatus;
import com.zjdiepu.www.base.enums.type.BusinessExtrasCodeType;
import com.zjdiepu.www.base.enums.type.BusinessExtrasType;
import com.zjdiepu.www.base.enums.type.DataDicType;
import com.zjdiepu.www.base.enums.type.ModeIDType;
import com.zjdiepu.www.base.enums.type.ResultFlagType;
import com.zjdiepu.www.common.util.CollectionInitUtil;
import com.zjdiepu.www.common.util.DateUtil;
import com.zjdiepu.www.common.util.UUIDFactory;
import com.zjdiepu.www.common.util.ZhppDateUtil;
import com.zjdiepu.www.commpent.helper.UserMapSalermanHelper;
import com.zjdiepu.www.dao.base.BaseAccountBusiUnitMapper;
import com.zjdiepu.www.dao.base.DpBaseDataDictionaryMapper;
import com.zjdiepu.www.dao.base.SysUserMapper;
import com.zjdiepu.www.dao.base.SysUserRoleMapper;
import com.zjdiepu.www.dao.dh.DhInsteadPaymentApplyMapper;
import com.zjdiepu.www.dao.fk.FkAuditListMapper;
import com.zjdiepu.www.dao.other.OtherAuditInfoMapper;
import com.zjdiepu.www.dao.other.OtherInboxMapper;
import com.zjdiepu.www.dao.other.OtherMessageAppMapper;
import com.zjdiepu.www.dao.other.OtherMessageHandleMapper;
import com.zjdiepu.www.dao.other.OtherShortMessageMapper;
import com.zjdiepu.www.dao.other.OtherWantWarningMapper;
import com.zjdiepu.www.dao.partner.ThAuditinfoMapper;
import com.zjdiepu.www.dao.system.BaseBusiUnitMapper;
import com.zjdiepu.www.dao.system.BaseSalersmanMapper;
import com.zjdiepu.www.dao.yw.YwBusinessExtrasMapper;
import com.zjdiepu.www.dao.yw.YwBusinessLoanEditMapper;
import com.zjdiepu.www.dao.yw.YwBusinessMapper;
import com.zjdiepu.www.dao.zpp.PublicDao;
import com.zjdiepu.www.dao.zx.ZxCreditQueryMapper;
import com.zjdiepu.www.dao.zx.ZxQueryCreditApplyMapper;
import com.zjdiepu.www.dao.zx.ZxQueryCreditApplySubMapper;
import com.zjdiepu.www.ibiz.base.ISysUserService;
import com.zjdiepu.www.ibiz.cache.ICachedDictionaryService;
import com.zjdiepu.www.ibiz.zpp.AppNewsService;
import com.zjdiepu.www.ibiz.zpp.SystemService;
import com.zjdiepu.www.model.base.dto.BaseAccountBusiUnit;
import com.zjdiepu.www.model.base.dto.DpBaseDataDictionary;
import com.zjdiepu.www.model.base.dto.SimpleDataDictionary;
import com.zjdiepu.www.model.base.dto.SysUser;
import com.zjdiepu.www.model.base.dto.SysUserRole;
import com.zjdiepu.www.model.dh.dto.DhInsteadPaymentApply;
import com.zjdiepu.www.model.fk.dto.FkAuditList;
import com.zjdiepu.www.model.fk.ext.FkAuditListExt;
import com.zjdiepu.www.model.other.dto.OtherAuditInfo;
import com.zjdiepu.www.model.other.dto.OtherInbox;
import com.zjdiepu.www.model.other.dto.OtherMessageApp;
import com.zjdiepu.www.model.other.dto.OtherShortMessage;
import com.zjdiepu.www.model.other.dto.OtherWantWarning;
import com.zjdiepu.www.model.partner.dto.ThAuditinfo;
import com.zjdiepu.www.model.system.dto.BaseBusiUnit;
import com.zjdiepu.www.model.system.dto.BaseSalersman;
import com.zjdiepu.www.model.yw.dto.YwBusiness;
import com.zjdiepu.www.model.yw.dto.YwBusinessExtras;
import com.zjdiepu.www.model.yw.dto.YwBusinessLoanEdit;
import com.zjdiepu.www.model.yw.request.YwBusinessQueryRequest;
import com.zjdiepu.www.model.zx.dto.ZxCreditQuery;
import com.zjdiepu.www.model.zx.dto.ZxQueryCreditApply;
import com.zjdiepu.www.model.zx.dto.ZxQueryCreditApplySub;
import com.zjdiepu.www.util.HtmlUtil;
import com.zjdiepu.www.util.PayloadBuild;


/**            
 *  项目名称：diepu-parent-biz      
 *  类名称：SystemServiceImpl      
 *  类描述：      
 *  创建人：zhangpp
 *  创建时间：2017年9月8日  上午11:45:22      
 *  修改人：zhangpp
 *  修改时间：2017年9月8日  上午11:45:22      
 *  修改备注：      
 *  @version  V1.0          
 */
@Service
public class SystemServiceImpl implements SystemService{

	private final Logger logger = LoggerFactory.getLogger(SystemServiceImpl.class);
	
	public static List<DpBaseDataDictionary> list = null;
	
	@Autowired
	private SysUserMapper sysUserMapper;
	
	@Autowired
	private PublicDao publicDao;
	
	@Autowired
	private ISysUserService iSysUserService;
	
	@Autowired
	private SysUserRoleMapper sysUserRoleMapper;
	
	@Autowired
	private BaseAccountBusiUnitMapper baseAccountBusiUnitMapper;
	
	@Autowired
	private BaseBusiUnitMapper baseBusiUnitMapper;
	
	@Autowired
	private BaseSalersmanMapper baseSalersmanMapper;
	
	@Autowired
	private OtherMessageHandleMapper otherMessageHandleMapper;
	
	@Autowired
	private YwBusinessMapper ywBusinessMapper;
	
	@Autowired
	private OtherMessageAppMapper otherMessageAppMapper;
	
	@Autowired
	private AppNewsService appNewsService;
	
	@Autowired
    private UserMapSalermanHelper userMapSalermanHelper;
	
	@Autowired
	private DpBaseDataDictionaryMapper dpBaseDataDictionaryMapper;
	
	@Autowired
	private ZxQueryCreditApplySubMapper zxQueryCreditApplySubMapper;
	
	@Autowired
    private ICachedDictionaryService cachedDictionaryService;
	
	@Autowired
	private ZxCreditQueryMapper zxCreditQueryMapper;
	
	@Autowired
	private ISysUserService isysUserService;
	
	@Autowired
	private FkAuditListMapper fkAuditListMapper;
	
	@Autowired
	private OtherAuditInfoMapper otherAuditInfoMapper;
	
	@Autowired
	private OtherShortMessageMapper otherShortMessageMapper;
	
	@Autowired
	private ZxQueryCreditApplyMapper zxQueryCreditApplyMapper;
	
	@Autowired
	private YwBusinessExtrasMapper ywBusinessExtrasMapper;
	
	@Autowired
	private OtherInboxMapper otherInboxMapper;
	
	@Autowired
	private OtherWantWarningMapper otherWantWarningMapper;
	
	@Autowired
	private ThAuditinfoMapper thAuditinfoMapper;
	
	@Autowired
	private DhInsteadPaymentApplyMapper dhInsteadPaymentApplyMapper;
	@Autowired
	private YwBusinessLoanEditMapper ywBusinessLoanEditMapper;

	/*  
	*  @author  zhangpp
	*  <p>Title:  passNew</p>  
	*  <p>Description:  </p>  
	*  @param currentUser
	*  @param pass
	*  @param passNew
	*  @param passNew1  
	*  @see com.zjdiepu.www.ibiz.zpp.SystemService#passNew(com.zjdiepu.www.base.core.AbstractSysUser, java.lang.String, java.lang.String, java.lang.String)  
	*  @version  V1.0
	*/
	@Override
	public void passNew(SysUser currentUser, String pass,
			String passNew, String passNew1) {
		
		
		String loginName = currentUser.getLoginName();
		
		String sqlXmls = "select count(t.id) count from sys_user t where t.login_name = '"+loginName+"' and t.login_pass = '"+pass+"' and t.dp_status = 1 ";
		int count = publicDao.countSqlXmls(sqlXmls);
		if(count < 1)
		{
			throw new BaseException(ResultFlagType.FAIL.getCode().toString(),"原始密码不正确");
		}
		
		if(!passNew.equals(passNew1))
		{
			throw new BaseException(ResultFlagType.FAIL.getCode().toString(),"两次密码输入不一致");
		}
		
		currentUser.setLoginPass(passNew);
		//添加修改人
		currentUser.initUpdateData(currentUser.getId(), currentUser.getName());
		count = sysUserMapper.updateByPrimaryKeySelective(currentUser);
		if(count < 1)
		{
			throw new BaseException(ResultFlagType.FAIL.getCode().toString(),"修改密码发生异常");
		}
	}

	/*  
	*  @author  zhangpp
	*  <p>Title:  getBankSqlXmls</p>  
	*  <p>Description:  </p>  
	*  @param bank
	*  @param field
	*  @return  
	*  @see com.zjdiepu.www.ibiz.zpp.SystemService#getBankSqlXmls(java.lang.String, java.lang.String)  
	*  @version  V1.0
	*/
	@Override
	public String getBankSqlXmls(String lBank, String field) {
		
		String whereSql = "";
		if(StringUtils.isNotBlank(lBank))
		{
			List<String> bankList = iSysUserService.listBankCodes(lBank);
			if(null != bankList && bankList.size() > 0)
			{
				whereSql = " and "+field+" in ( ";
				for(String bank : bankList)
				{
					whereSql += "'"+bank+"',";
				}
				whereSql = whereSql.substring(0,whereSql.length()-1);
				whereSql += " ) ";
			}
		}
		return whereSql;
	}

	/*  
	*  @author  zhangpp
	*  <p>Title:  register</p>  
	*  <p>Description:  </p>  
	*  @param phone
	*  @param pass
	*  @return  
	*  @see com.zjdiepu.www.ibiz.zpp.SystemService#register(java.lang.String, java.lang.String)  
	*  @version  V1.0
	*/
	@Override
	public Map<String, String> register(String phone, String pass,String orgId,String roleId,String salersmanId,String salersmanCode,String codeUnit,String idUnit) {
		
		
		//注册用户
		SysUser sysUser = new SysUser();
		sysUser.initInsertData("00000000000000000000000000000000", "移动端注册");
		sysUser.setLoginName(phone);
		sysUser.setUname(phone);
		sysUser.setSalersmanId(salersmanId);
		sysUser.setSalersmanCode(salersmanCode);
		sysUser.setAccountType(0);
		sysUser.setLoginType(0);
		sysUser.setLoginPass(pass);
		sysUser.setOrgId(orgId);
		sysUser.setTypeData(3);
		int count = sysUserMapper.insert(sysUser);
		if(count < 1)
		{
			throw new BaseException(ResultFlagType.FAIL.getCode().toString(),ResultFlagType.FAIL.getValue());
		}
		
		//给予角色
		SysUserRole sysUserRole = new SysUserRole();
		sysUserRole.initInsertData(sysUser.getId(), sysUser.getUname());
		sysUserRole.setUserId(sysUser.getId());
		sysUserRole.setRoleId(roleId);
		count = sysUserRoleMapper.insert(sysUserRole);
		if(count < 1)
		{
			throw new BaseException(ResultFlagType.FAIL.getCode().toString(),ResultFlagType.FAIL.getValue());
		}
		
		//给予业务员权限
		BaseAccountBusiUnit baseAccountBusiUnit = new BaseAccountBusiUnit();
		baseAccountBusiUnit.initInsertData(sysUser.getId(), sysUser.getUname());
		baseAccountBusiUnit.setUserId(sysUser.getId());
		baseAccountBusiUnit.setIdUnit(idUnit);
		baseAccountBusiUnit.setCodeUnit(codeUnit);
		count = baseAccountBusiUnitMapper.insert(baseAccountBusiUnit);
		if(count < 1)
		{
			throw new BaseException(ResultFlagType.FAIL.getCode().toString(),ResultFlagType.FAIL.getValue());
		}
		
		Map<String, String> result = CollectionInitUtil.emptyMap();
		result.put("loginName", phone);
		result.put("loginPass", pass);
		return result;
	}

	
	@Override
	public void diepuNewsHandle(AbstractSysUser currentUser,String modeId,String typeMsgEvent,String busiId,String queryCreditApplySubId, String... moreParam)
	{
		
		
		//查询消息处理表
		String sqlXmls = "select t.id,t.type_msg_event,t.status_msg_handle,t.value_msg_handle from other_message_handle t where t.dp_status = 1 and t.type_msg_event = '"+typeMsgEvent+"'";
		List<Map<String, String>> result = publicDao.queryWhereSql(sqlXmls);
		
		//消息不处理
		if(null == result || 0 == result.size())
		{
			return;
		}
		
		//当前时间
		Date now = new Date();
		String nowString = DateUtil.dateTo14String(now);
		
		//消息处理状态  01：发短息 02：发送APP推送  03：发送站内容
		//消息处理值   0：不处理  1：需要处理
		
		//查询业务信息表
		YwBusiness business = ywBusinessMapper.selectByPrimaryKey(busiId);
		
		//客户姓名
		String cusName = "无";
		String dataId = null;
		if(ArrayUtils.isNotEmpty(moreParam)) {
			dataId = moreParam[0];
		}
		String salesmanId = "";
		String queryCreditApplyId = "";
		String receiverId = "";
		
		if(null != business)
		{
			cusName = business.getCustomerName();
			salesmanId = business.getSalesmanId();
			queryCreditApplyId = business.getQueryCreditApplyId();
			receiverId = business.getOperatorId();
		}
		String currentUserId = currentUser == null ? "调度任务" : currentUser.getId();
		String currentUserName = currentUser == null ? "调度任务" : currentUser.getName();
		//推送消息处理
		OtherMessageApp otherMessageApp = new OtherMessageApp();
		otherMessageApp.initInsertData(currentUserId, currentUserName);
		otherMessageApp.setBusiId(busiId);
		otherMessageApp.setDataid(dataId);
		otherMessageApp.setTypeMsgEvent(typeMsgEvent);
		otherMessageApp.setChannelSend("https://www.jiguang.cn/");
		otherMessageApp.setTimeCreate(now);
		otherMessageApp.setTimeSend(now);
		otherMessageApp.setSalesmanId(salesmanId);
		otherMessageApp.setModeId(modeId);
		String notificationBar = "<"+cusName+">";
		String title = "<"+cusName+">";
		String content = "";
		String typeApp = "";
		String imei = "";
		String typeMsg = "02"; //提示 01 通知	02 预警	03
		otherMessageApp.setTypeMsg(typeMsg);

		String msgId = "";
		int statusMsg = 10;
		//推送消息处理
		
		//发送短信处理
		OtherShortMessage otherShortMessage = new OtherShortMessage();
		otherShortMessage.initInsertData(currentUserId, currentUserName);
		otherShortMessage.setTypeMsgEvent(typeMsgEvent);
		otherShortMessage.setBusiId(busiId);
		otherShortMessage.setDataid(dataId);
		otherShortMessage.setChannelSend("https://www.juhe.cn/");
		otherShortMessage.setTimeCreate(now);
		otherShortMessage.setTimeSend(now);
		otherShortMessage.setTypeMsg(typeMsg);
		//发送短信处理
		
		
		//发送站内容
		OtherInbox otherInbox = new OtherInbox();
		otherInbox.initInsertData(currentUserId, currentUserName);
		otherInbox.setBusiId(busiId);
		otherInbox.setModeId(modeId);
		otherInbox.setTypeMsgEvent(typeMsgEvent);
		otherInbox.setReceiverId(receiverId);
		//发送站内容
		
		//修改征信申请
		if(typeMsgEvent.equals("01"))
		{			
			for(int i=0;i<result.size();i++)
			{
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				
				if(value_msg_handle.equals("1"))
				{
					if(status_msg_handle.equals("01"))
					{
						otherShortMessage.setModeId("M_zxug");
						ZxQueryCreditApplySub zxQueryCreditApplySub = zxQueryCreditApplySubMapper.selectByPrimaryKey(queryCreditApplySubId);
						String reasonBack = "无";
						if(null != zxQueryCreditApplySub)
						{
							reasonBack = cachedDictionaryService.getName(zxQueryCreditApplySub.getReasonBack(), DataDicType.CREDIT_RETURNED_REASON);
							cusName = zxQueryCreditApplySub.getCusName();
						}
						content += "客户<"+cusName+"> 征信查询申请被退回。原因：<"+reasonBack+">";
						
						ZxQueryCreditApply zxQueryCreditApply = zxQueryCreditApplyMapper.selectByPrimaryKey(zxQueryCreditApplySub.getQueryCreditApplyId());
						if(null != zxQueryCreditApply)
						{
							salesmanId = zxQueryCreditApply.getSalersmanIdThen();
							otherShortMessage.setContent(content);
						}
					}
					else if(status_msg_handle.equals("02"))
					{
						content = "客户<"+cusName+">";
						ZxQueryCreditApplySub zxQueryCreditApplySub = zxQueryCreditApplySubMapper.selectByPrimaryKey(queryCreditApplySubId);
						String reasonBack = "无";
						if(null != zxQueryCreditApplySub)
						{
							reasonBack = cachedDictionaryService.getName(zxQueryCreditApplySub.getReasonBack(), DataDicType.CREDIT_RETURNED_REASON);
							cusName = zxQueryCreditApplySub.getCusName();
						}
						title = "<"+cusName+">";
						notificationBar = "<"+cusName+">";
						notificationBar += "征信查询申请被退回";
						title += "征信查询申请被退回";
						content += "事件：<"+cusName+"> 征信查询申请被退回/n";
						content += "原因：<"+reasonBack+">/n";
						ZxCreditQuery zxCreditQuery = new ZxCreditQuery();
						zxCreditQuery.setQueryCreditApplySubId(queryCreditApplySubId);
						zxCreditQuery.setDpStatus(1);
						zxCreditQuery = zxCreditQueryMapper.selectRefined(zxCreditQuery);
						String remarks = "无";
						if(null != zxCreditQuery)
						{
							remarks = zxCreditQuery.getRemarks();
						}
						content += "备注：<"+remarks+">";
						ZxQueryCreditApply zxQueryCreditApply = zxQueryCreditApplyMapper.selectByPrimaryKey(zxQueryCreditApplySub.getQueryCreditApplyId());
						if(null != zxQueryCreditApply)
						{
							salesmanId = zxQueryCreditApply.getSalersmanIdThen();
//							@update 2018-02-27 02为App推送，不发短信
//							otherShortMessage.setContent(content);
						}
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setModeId("M_zxug");
						otherMessageApp.setSalesmanId(salesmanId);
					}
					else if(status_msg_handle.equals("03"))
					{
						
					}
				}
			}
		}
		//不做征信查询
		else if(typeMsgEvent.equals("02"))
		{
			for(int i=0;i<result.size();i++)
			{
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				
				if(value_msg_handle.equals("1"))
				{
					if(status_msg_handle.equals("01"))
					{
						otherShortMessage.setModeId("M_bzzxcx");
						ZxQueryCreditApplySub zxQueryCreditApplySub = zxQueryCreditApplySubMapper.selectByPrimaryKey(queryCreditApplySubId);
						if(null != zxQueryCreditApplySub)
						{
							cusName = zxQueryCreditApplySub.getCusName();
						}
						content += "客户<"+cusName+"> 征信查询申请被拒。原因：银行拒绝";
						ZxQueryCreditApply zxQueryCreditApply = zxQueryCreditApplyMapper.selectByPrimaryKey(zxQueryCreditApplySub.getQueryCreditApplyId());
						if(null != zxQueryCreditApply)
						{
							salesmanId = zxQueryCreditApply.getSalersmanIdThen();
							otherShortMessage.setContent(content);
						}
						otherShortMessage.setContent(content);
					}
					else if(status_msg_handle.equals("02"))
					{
						content = "客户<"+cusName+">";
						ZxQueryCreditApplySub zxQueryCreditApplySub = zxQueryCreditApplySubMapper.selectByPrimaryKey(queryCreditApplySubId);
						if(null != zxQueryCreditApplySub)
						{
							cusName = zxQueryCreditApplySub.getCusName();
						}
						title = "<"+cusName+">";
						notificationBar = "<"+cusName+">";
						notificationBar += "征信查询申请被拒";
						title += "征信查询申请被拒";
						content += "事件：<"+cusName+"> 征信查询申请被拒绝/n";
						content += "原因：银行拒绝查询";
						ZxQueryCreditApply zxQueryCreditApply = zxQueryCreditApplyMapper.selectByPrimaryKey(zxQueryCreditApplySub.getQueryCreditApplyId());
						if(null != zxQueryCreditApply)
						{
							salesmanId = zxQueryCreditApply.getSalersmanIdThen();
//							@update 2018-02-27 02为App推送，不发短信
//							otherShortMessage.setContent(content);
						}
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setModeId("M_bzzxcx");
						otherMessageApp.setSalesmanId(salesmanId);
					}
					else if(status_msg_handle.equals("03"))
					{
						
					}
				}
			}
		}
		//征信结果
		else if(typeMsgEvent.equals("03"))
		{
			for(int i=0;i<result.size();i++)
			{
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				
				if(value_msg_handle.equals("1"))
				{
					if(status_msg_handle.equals("01"))
					{
						otherShortMessage.setModeId("M_zxjg");
						ZxQueryCreditApplySub zxQueryCreditApplySub = zxQueryCreditApplySubMapper.selectByPrimaryKey(queryCreditApplySubId);
						if(null != zxQueryCreditApplySub)
						{
							cusName = zxQueryCreditApplySub.getCusName();
						}
						ZxCreditQuery zxCreditQuery = new ZxCreditQuery();
						zxCreditQuery.setQueryCreditApplySubId(queryCreditApplySubId);
						zxCreditQuery.setDpStatus(1);
						zxCreditQuery = zxCreditQueryMapper.selectRefined(zxCreditQuery);
//						String credit_result_mark = "无";
//						if(null != zxCreditQuery)
//						{
//							credit_result_mark = HtmlUtil.filterHtml(zxCreditQuery.getCreditResultMark());
//						}
//						content += "客户<"+cusName+"> 征信查询结果：<已查询>；备注：<"+credit_result_mark+">";
						content = "";
						content += "<"+cusName+"> 征信查询结果：<已查询>";
						ZxQueryCreditApply zxQueryCreditApply = zxQueryCreditApplyMapper.selectByPrimaryKey(zxQueryCreditApplySub.getQueryCreditApplyId());
						if(null != zxQueryCreditApply)
						{
							salesmanId = zxQueryCreditApply.getSalersmanIdThen();
							otherShortMessage.setContent(content);
						}
						otherShortMessage.setContent(content);
					}
					else if(status_msg_handle.equals("02"))
					{
						content = "客户<"+cusName+">";
						ZxCreditQuery zxCreditQuery = new ZxCreditQuery();
						zxCreditQuery.setQueryCreditApplySubId(queryCreditApplySubId);
						zxCreditQuery.setDpStatus(1);
						zxCreditQuery = zxCreditQueryMapper.selectRefined(zxCreditQuery);
						String credit_result_mark = "无";
						String onceCarStatus = "";
						String[] onceName = {"均无","曾有灰名单","现有灰名单","外部欺诈客户","交叉违约"};
						String[] onceCode = {"01","02","03","04","05"};
						String creditResult = "";
						if(null != zxCreditQuery)
						{
							credit_result_mark = HtmlUtil.filterHtml(zxCreditQuery.getCreditResultMark());
							if(StringUtils.isNotBlank(zxCreditQuery.getOnceCarStatus()))
							{
								String[] tmep = zxCreditQuery.getOnceCarStatus().split(",");
								for(int j=0;j<onceCode.length;j++)
								{
									for(int x=0;x<tmep.length;x++)
									{
										if(onceCode[j].equals(tmep[x]))
										{
											onceCarStatus += onceName[j]+",";
											break;
										}
									}
								}
								
								if(StringUtils.isNotBlank(onceCarStatus))
								{
									onceCarStatus = onceCarStatus.substring(0,onceCarStatus.length()-1);
								}
							}
							if(StringUtils.isNotBlank(zxCreditQuery.getCreditResult()))
							{
								if(zxCreditQuery.getCreditResult().equals("01"))
								{
									creditResult = "正常";
								}
								else if(zxCreditQuery.getCreditResult().equals("02"))
								{
									creditResult = "关注";
								}
								else if(zxCreditQuery.getCreditResult().equals("03"))
								{
									creditResult = "禁入";
								}
							}
						}
						
						ZxQueryCreditApplySub zxQueryCreditApplySub = zxQueryCreditApplySubMapper.selectByPrimaryKey(queryCreditApplySubId);
						String creditPeopleType = "无";
						if(null != zxQueryCreditApplySub)
						{
							creditPeopleType = cachedDictionaryService.getName(zxQueryCreditApplySub.getCreditPeopleType(), DataDicType.CREDIT_PEOPLE_TYPE);
							cusName = zxQueryCreditApplySub.getCusName();
						}
						title = "<"+cusName+">";
						notificationBar = "<"+cusName+">"; 
						title += "征信查询结果：<已查询>";
						notificationBar += "征信查询结果：<已查询>";
						content += "客户角色：<"+creditPeopleType+">\n";
						
						ZxQueryCreditApplySub queryCreditApplySub = new ZxQueryCreditApplySub();
						queryCreditApplySub.setQueryCreditApplyId(queryCreditApplyId);
						queryCreditApplySub.setCreditPeopleType("03");
						queryCreditApplySub.setDpStatus(1);
						queryCreditApplySub = zxQueryCreditApplySubMapper.selectRefined(zxQueryCreditApplySub);
						String creditTypeName = "";
						if(null != queryCreditApplySub)
						{
							creditTypeName = queryCreditApplySub.getCusName();
						}
						content += "主借人：<"+creditTypeName+">\n";
						content += "开卡状态：<"+onceCarStatus+">\n";
						content += "信用状态：<"+creditResult+">\n";
						content += "备注信息：<"+HtmlUtil.filterHtml(credit_result_mark)+">\n";
						ZxQueryCreditApply zxQueryCreditApply = zxQueryCreditApplyMapper.selectByPrimaryKey(zxQueryCreditApplySub.getQueryCreditApplyId());
						if(null != zxQueryCreditApply)
						{
							salesmanId = zxQueryCreditApply.getSalersmanIdThen();
//							@update 2018-02-07 短信模板修改
//							@update 2018-02-27 02为App推送，不发短信
//							String shortMsgContent = "客户<"+creditTypeName+"> 征信查询结果：<"+creditResult+">，详情请登录APP查看";
//							otherShortMessage.setContent(shortMsgContent);
						}
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setModeId("M_zxjg");
						otherMessageApp.setSalesmanId(salesmanId);
					}
					else if(status_msg_handle.equals("03"))
					{
						
					}
				}
			}
		}
		//初审单初审结果
		else if(typeMsgEvent.equals("04"))
		{
			for(int i=0;i<result.size();i++)
			{
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				
				if(value_msg_handle.equals("1"))
				{
					if(status_msg_handle.equals("01"))
					{
						otherShortMessage.setModeId(ModeIDType.CSDCS.getCode());
						FkAuditList fkAuditList = new FkAuditList();
						fkAuditList.setBusiId(busiId);
						fkAuditList.setModeId(ModeIDType.CSDCS.getCode());
						fkAuditList.setDpStatus(1);
						fkAuditList = fkAuditListMapper.selectRefined(fkAuditList);
						String statusListName = "";
						if(null != fkAuditList)
						{
							statusListName = cachedDictionaryService.getName(String.valueOf(fkAuditList.getStatusList()), DataDicType.AUDITLISTSTATUS);
						}
						content += "客户<"+cusName+"> 初审一审结果：<"+statusListName+"> 详情请登录客户端查询";
						otherShortMessage.setContent(content);
					}
					else if(status_msg_handle.equals("02"))
					{
						content = "客户<"+cusName+">";
						FkAuditList fkAuditList = new FkAuditList();
						fkAuditList.setBusiId(busiId);
						fkAuditList.setModeId(ModeIDType.CSDCS.getCode());
						fkAuditList.setDpStatus(1);
						fkAuditList = fkAuditListMapper.selectRefined(fkAuditList);
						String statusListName = "";
						if(null != fkAuditList)
						{
							statusListName = cachedDictionaryService.getName(String.valueOf(fkAuditList.getStatusList()), DataDicType.AUDITLISTSTATUS);
						}
						notificationBar += "初审一审结果：<"+statusListName+">";
						title += "初审一审结果：<"+statusListName+">";
						
						OtherAuditInfo otherAuditInfo = new OtherAuditInfo();
						otherAuditInfo.setBusiId(busiId);
						otherAuditInfo.setModeId(ModeIDType.CSDCS.getCode());
						otherAuditInfo.setDpStatus(1);
						otherAuditInfo = otherAuditInfoMapper.selectRefined(otherAuditInfo);
						String auditDetail = "";
						String auditPostil = "";
						if(null != otherAuditInfo)
						{
							auditDetail = otherAuditInfo.getAuditDetail();
							auditPostil = otherAuditInfo.getAuditPostil();
						}
						
						content += "审核结果：<"+statusListName+">/n";
						content += "审核详情：<"+auditDetail+">/n";
						content += "审核批注：<"+HtmlUtil.filterHtml(auditPostil)+">/n";
						content += "附加条件：<条件1>/n";
						content += "<条件2>/n";
						content += "经办人：<"+currentUserName+">/n";
						content += "经办时间：<"+nowString+">";
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setModeId(ModeIDType.CSDCS.getCode());
						otherMessageApp.setSalesmanId(salesmanId);
					}
					else if(status_msg_handle.equals("03"))
					{
						
					}
				}
			}
		}	
		//初审单终审结果
		else if(typeMsgEvent.equals("05"))
		{
			for(int i=0;i<result.size();i++)
			{
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				
				if(value_msg_handle.equals("1"))
				{
					if(status_msg_handle.equals("01"))
					{
						otherShortMessage.setModeId(modeId);
						FkAuditList fkAuditList = new FkAuditList();
						fkAuditList.setBusiId(busiId);
						fkAuditList.setModeId(modeId);
						fkAuditList.setDpStatus(1);
						fkAuditList = fkAuditListMapper.selectRefined(fkAuditList);
						String statusListName = "";
						if(null != fkAuditList)
						{
							statusListName = cachedDictionaryService.getName(String.valueOf(fkAuditList.getStatusList()), DataDicType.AUDITLISTSTATUS);
						}
//						content += "客户<"+cusName+"> 初审二审结果：<"+statusListName+"> 详情请登录客户端查询";
						content = "";
						content += "<"+cusName+"> 初审二审结果：<"+statusListName+">";
						otherShortMessage.setContent(content);
					}
					else if(status_msg_handle.equals("02"))
					{
						content = "客户<"+cusName+">";
						FkAuditList fkAuditList = new FkAuditList();
						fkAuditList.setBusiId(busiId);
						fkAuditList.setModeId(modeId);
						fkAuditList.setDpStatus(1);
						fkAuditList = fkAuditListMapper.selectRefined(fkAuditList);
						String statusListName = "";
						if(null != fkAuditList)
						{
							statusListName = cachedDictionaryService.getName(String.valueOf(fkAuditList.getStatusList()), DataDicType.AUDITLISTSTATUS);
						}
						notificationBar += "初审一审结果：<"+statusListName+">";
						title += "初审一审结果：<"+statusListName+">";
						
						OtherAuditInfo otherAuditInfo = new OtherAuditInfo();
						otherAuditInfo.setBusiId(busiId);
						otherAuditInfo.setModeId(modeId);
						otherAuditInfo.setDpStatus(1);
						otherAuditInfo = otherAuditInfoMapper.selectRefined(otherAuditInfo);
						String auditDetail = "";
						String auditPostil = "";
						if(null != otherAuditInfo)
						{
							auditDetail = otherAuditInfo.getAuditDetail();
							auditPostil = otherAuditInfo.getAuditPostil();
						}
						
						content += "审核结果：<"+statusListName+">/n";
						content += "审核详情：<"+auditDetail+">/n";
						content += "审核批注：<"+HtmlUtil.filterHtml(auditPostil)+">/n";
						content += "附加条件：<条件1>/n";
						content += "<条件2>/n";
						content += "经办人：<"+currentUserName+">/n";
						content += "经办时间：<"+nowString+">";
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setModeId(ModeIDType.CSDZS.getCode());
						otherMessageApp.setSalesmanId(salesmanId);
					}
					else if(status_msg_handle.equals("03"))
					{
						
					}
				}
			}
		}
		//风控总监审批结果
		else if(typeMsgEvent.equals("11"))
		{
			for(int i=0;i<result.size();i++)
			{
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				
				if(value_msg_handle.equals("1"))
				{
					if(status_msg_handle.equals("01"))
					{
						otherShortMessage.setModeId(modeId);
						FkAuditList fkAuditList = new FkAuditList();
						fkAuditList.setBusiId(busiId);
						fkAuditList.setModeId(modeId);
						fkAuditList.setDpStatus(1);
						fkAuditList = fkAuditListMapper.selectRefined(fkAuditList);
						String statusListName = "";
						if(null != fkAuditList)
						{
							statusListName = cachedDictionaryService.getName(String.valueOf(fkAuditList.getStatusList()), DataDicType.AUDITLISTSTATUS);
						}
//						content += "客户<"+cusName+"> 初审一审结果：<"+statusListName+"> 详情请登录客户端查询";
						content = "";
						content += "<"+cusName+"> 风控总监审批结果：<"+statusListName+">";
						otherShortMessage.setContent(content);
					}
					else if(status_msg_handle.equals("02"))
					{
						content = "客户<"+cusName+">";
						FkAuditList fkAuditList = new FkAuditList();
						fkAuditList.setBusiId(busiId);
						fkAuditList.setModeId(modeId);
						fkAuditList.setDpStatus(1);
						fkAuditList = fkAuditListMapper.selectRefined(fkAuditList);
						String statusListName = "";
						if(null != fkAuditList)
						{
							statusListName = cachedDictionaryService.getName(String.valueOf(fkAuditList.getStatusList()), DataDicType.AUDITLISTSTATUS);
						}
						notificationBar += "初审一审结果：<"+statusListName+">";
						title += "初审一审结果：<"+statusListName+">";
						
						OtherAuditInfo otherAuditInfo = new OtherAuditInfo();
						otherAuditInfo.setBusiId(busiId);
						otherAuditInfo.setModeId(ModeIDType.FKZJSH.getCode());
						otherAuditInfo.setDpStatus(1);
						otherAuditInfo = otherAuditInfoMapper.selectRefined(otherAuditInfo);
						String auditDetail = "";
						String auditPostil = "";
						if(null != otherAuditInfo)
						{
							auditDetail = otherAuditInfo.getAuditDetail();
							auditPostil = otherAuditInfo.getAuditPostil();
						}
						
						content += "审核结果：<"+statusListName+">/n";
						content += "审核详情：<"+auditDetail+">/n";
						content += "审核批注：<"+HtmlUtil.filterHtml(auditPostil)+">/n";
						content += "附加条件：<条件1>/n";
						content += "<条件2>/n";
						content += "经办人：<"+currentUserName+">/n";
						content += "经办时间：<"+nowString+">";
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setModeId(ModeIDType.FKZJSH.getCode());
					}
					else if(status_msg_handle.equals("03"))
					{
						try 
						{
							content = "客户<"+cusName+">";
							FkAuditList fkAuditList = new FkAuditList();
							fkAuditList.setBusiId(busiId);
							fkAuditList.setModeId(modeId);
							fkAuditList.setDpStatus(1);
							fkAuditList = fkAuditListMapper.selectRefined(fkAuditList);
							String statusListName = "";
							if(null != fkAuditList)
							{
								statusListName = cachedDictionaryService.getName(String.valueOf(fkAuditList.getStatusList()), DataDicType.AUDITLISTSTATUS);
								statusListName = cachedDictionaryService.getName(String.valueOf(fkAuditList.getStatusList()), DataDicType.AUDITLISTSTATUS);
							}
							String titleInbox = "<"+cusName+"> 风控总监审批结果：<"+statusListName+"> ";
							otherInbox.setTitleInbox(titleInbox);
							
							OtherAuditInfo otherAuditInfo = new OtherAuditInfo();
							otherAuditInfo.setBusiId(busiId);
							otherAuditInfo.setModeId(ModeIDType.FKZJSH.getCode());
							otherAuditInfo.setDpStatus(1);
							otherAuditInfo = otherAuditInfoMapper.selectRefined(otherAuditInfo);
							String auditDetail = "";
							String auditPostil = "";
							if(null != otherAuditInfo)
							{
								auditDetail = otherAuditInfo.getAuditDetail();
								auditPostil = otherAuditInfo.getAuditPostil();
							}
							content += "审核结果：<"+statusListName+">/n";
							content += "审核详情：<"+auditDetail+">/n";
							content += "审核批注：<"+HtmlUtil.filterHtml(auditPostil)+">/n";
							content += "附加条件：<条件1>/n";
							content += "<条件2>/n";
							content += "经办人：<"+currentUserName+">/n";
							content += "经办时间：<"+nowString+">";
							otherInbox.setContentInbox(content);
							otherInbox.setDateInbox(now);
							otherInbox.setStatusInbox(1);
							otherInbox.setDateFirstRead(now);
							otherInboxMapper.insert(otherInbox);
						} 
						catch (Exception e) 
						{
							
							logger.error(e.getMessage());
						}
					}
				}
			}
		}
		//风控退回
		else if(typeMsgEvent.equals("26"))
		{
			for(int i=0;i<result.size();i++)
			{
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				
				if(value_msg_handle.equals("1"))
				{
					if(status_msg_handle.equals("01"))
					{
						otherShortMessage.setModeId(modeId);
						FkAuditList fkAuditList = new FkAuditList();
						fkAuditList.setBusiId(busiId);
						fkAuditList.setModeId(modeId);
						fkAuditList.setDpStatus(1);
						fkAuditList = fkAuditListMapper.selectRefined(fkAuditList);
						String statusListName = "";
						if(null != fkAuditList)
						{
							statusListName = cachedDictionaryService.getName(String.valueOf(fkAuditList.getStatusList()), DataDicType.AUDITLISTSTATUS);
						}
						content += "客户<"+cusName+"> 初审一审结果：<"+statusListName+"> 详情请登录客户端查询";
						otherShortMessage.setContent(content);
					}
					else if(status_msg_handle.equals("02"))
					{
						content = "客户<"+cusName+">";
						FkAuditList fkAuditList = new FkAuditList();
						fkAuditList.setBusiId(busiId);
						fkAuditList.setModeId(modeId);
						fkAuditList.setDpStatus(1);
						fkAuditList = fkAuditListMapper.selectRefined(fkAuditList);
						String statusListName = "";
						if(null != fkAuditList)
						{
							statusListName = cachedDictionaryService.getName(String.valueOf(fkAuditList.getStatusList()), DataDicType.AUDITLISTSTATUS);
						}
						notificationBar += "初审一审结果：<"+statusListName+">";
						title += "初审一审结果：<"+statusListName+">";
						
						OtherAuditInfo otherAuditInfo = new OtherAuditInfo();
						otherAuditInfo.setBusiId(busiId);
						otherAuditInfo.setModeId(modeId);
						otherAuditInfo.setDpStatus(1);
						otherAuditInfo = otherAuditInfoMapper.selectRefined(otherAuditInfo);
						String auditDetail = "";
						String auditPostil = "";
						if(null != otherAuditInfo)
						{
							auditDetail = otherAuditInfo.getAuditDetail();
							auditPostil = otherAuditInfo.getAuditPostil();
						}
						content += "审核结果：<"+statusListName+">/n";
						content += "审核详情：<"+auditDetail+">/n";
						content += "审核批注：<"+HtmlUtil.filterHtml(auditPostil)+">/n";
						content += "附加条件：<条件1>/n";
						content += "<条件2>/n";
						content += "经办人：<"+currentUserName+">/n";
						content += "经办时间：<"+nowString+">";
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setModeId(modeId);
					}
					else if(status_msg_handle.equals("03"))
					{
						
					}
				}
			}
		}
		//风控加收押金和GPS
		else if(typeMsgEvent.equals("27"))
		{
			for(int i=0;i<result.size();i++)
			{
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				
				if(value_msg_handle.equals("1"))
				{
					if(status_msg_handle.equals("01"))
					{
//						content = "";
//						otherShortMessage.setModeId(modeId);
//						YwBusinessExtras ywBusinessExtras = new YwBusinessExtras();
//						ywBusinessExtras.setBusiId(busiId);
//						ywBusinessExtras.setCodeExtras(BusinessExtrasCodeType.ADD_GPS.getCode());
//						ywBusinessExtras.setTypeExtras(BusinessExtrasType.AUDIT.getCode());
//						ywBusinessExtras.setDpStatus(1);
//						ywBusinessExtras = ywBusinessExtrasMapper.selectRefined(ywBusinessExtras);
//						String gpsNum = "0";
//						if(null != ywBusinessExtras)
//						{
//							gpsNum = ywBusinessExtras.getValueExtras();
//						}
//						ywBusinessExtras = new YwBusinessExtras();
//						ywBusinessExtras.setBusiId(busiId);
//						ywBusinessExtras.setCodeExtras(BusinessExtrasCodeType.ADD_GEPOSIT.getCode());
//						ywBusinessExtras.setTypeExtras(BusinessExtrasType.AUDIT.getCode());
//						ywBusinessExtras.setDpStatus(1);
//						ywBusinessExtras = ywBusinessExtrasMapper.selectRefined(ywBusinessExtras);
//						String jine = "0";
//						if(null != ywBusinessExtras)
//						{
//							jine = ywBusinessExtras.getValueExtras();
//						}
//						ywBusinessExtras = new YwBusinessExtras();
//						ywBusinessExtras.setBusiId(busiId);
//						ywBusinessExtras.setCodeExtras(BusinessExtrasCodeType.FLEXIBLECHARGE.getCode());
//						ywBusinessExtras.setTypeExtras(BusinessExtrasType.AUDIT.getCode());
//						ywBusinessExtras.setDpStatus(1);
//						ywBusinessExtras = ywBusinessExtrasMapper.selectRefined(ywBusinessExtras);
//						String sfbt = "0";
//						if(null != ywBusinessExtras)
//						{
//							sfbt = ywBusinessExtras.getValueExtras();
//						}
//						ywBusinessExtras = new YwBusinessExtras();
//						ywBusinessExtras.setBusiId(busiId);
//						ywBusinessExtras.setCodeExtras(BusinessExtrasCodeType.IS_SPECIAL_ORDER.getCode());
//						ywBusinessExtras.setTypeExtras(BusinessExtrasType.AUDIT.getCode());
//						ywBusinessExtras.setDpStatus(1);
//						ywBusinessExtras = ywBusinessExtrasMapper.selectRefined(ywBusinessExtras);
//						String tsdd = "0";
//						if(null != ywBusinessExtras)
//						{
//							tsdd = ywBusinessExtras.getValueExtras();
//						}
//						tsdd = "0".equals(tsdd) ? "是":"否";
//						content += "客户<"+cusName+"> 需办征信信 加收押金<"+jine+">元；加装GPS<"+gpsNum+">个；收费变通<"+ sfbt + ">；特殊订单";
						content =  "客户<"+cusName+">的风控过审附加条件有更新，请去APP收件箱查看详情";
						otherShortMessage.setContent(content);
					}
					else if(status_msg_handle.equals("02"))
					{
//						content = "客户<"+cusName+">";
						YwBusinessExtras ywBusinessExtras = new YwBusinessExtras();
						ywBusinessExtras.setBusiId(busiId);
						ywBusinessExtras.setCodeExtras(BusinessExtrasCodeType.ADD_GPS.getCode());
						ywBusinessExtras.setTypeExtras(BusinessExtrasType.AUDIT.getCode());
						ywBusinessExtras.setDpStatus(1);
						ywBusinessExtras = ywBusinessExtrasMapper.selectRefined(ywBusinessExtras);
						String gpsNum = "0";
						if(null != ywBusinessExtras)
						{
							gpsNum = ywBusinessExtras.getValueExtras();
						}
						ywBusinessExtras = new YwBusinessExtras();
						ywBusinessExtras.setBusiId(busiId);
						ywBusinessExtras.setCodeExtras(BusinessExtrasCodeType.ADD_GEPOSIT.getCode());
						ywBusinessExtras.setTypeExtras(BusinessExtrasType.AUDIT.getCode());
						ywBusinessExtras.setDpStatus(1);
						ywBusinessExtras = ywBusinessExtrasMapper.selectRefined(ywBusinessExtras);
						String jine = "0";
						if(null != ywBusinessExtras)
						{
							jine = ywBusinessExtras.getValueExtras();
						}
						ywBusinessExtras = new YwBusinessExtras();
						ywBusinessExtras.setBusiId(busiId);
						ywBusinessExtras.setCodeExtras(BusinessExtrasCodeType.FLEXIBLECHARGE.getCode());
						ywBusinessExtras.setTypeExtras(BusinessExtrasType.AUDIT.getCode());
						ywBusinessExtras.setDpStatus(1);
						ywBusinessExtras = ywBusinessExtrasMapper.selectRefined(ywBusinessExtras);
						String sfbt = "0";
						if(null != ywBusinessExtras)
						{
							sfbt = ywBusinessExtras.getValueExtras();
						}
						ywBusinessExtras = new YwBusinessExtras();
						ywBusinessExtras.setBusiId(busiId);
						ywBusinessExtras.setCodeExtras(BusinessExtrasCodeType.IS_SPECIAL_ORDER.getCode());
						ywBusinessExtras.setTypeExtras(BusinessExtrasType.AUDIT.getCode());
						ywBusinessExtras.setDpStatus(1);
						ywBusinessExtras = ywBusinessExtrasMapper.selectRefined(ywBusinessExtras);
						String tsdd = "0";
						if(null != ywBusinessExtras)
						{
							tsdd = ywBusinessExtras.getValueExtras();
						}
						tsdd = "0".equals(tsdd) ? "否":"是";
						String notificationBar_ = "客户<"+cusName+">的风控过审附加条件有更新，请去收件箱查看详情";
						otherMessageApp.setNotificationBar(notificationBar_);
						otherMessageApp.setTitle(notificationBar_);
						String content_ = "客户：<"+cusName+">/n";
						content_ += "附加条件：征信加收押金<"+jine+">元/n";
						content_ += "加装GPS<"+gpsNum+">个/n";
						content_ += "收费变通<"+ sfbt + ">元/n";
						content_ += "延迟收款<"+ tsdd + ">/n";
						content_ += "经办人：<" + currentUserName + ">/n";
						content_ += "经办时间：<" + nowString + ">/n";
						otherMessageApp.setContent(content_);
						otherMessageApp.setModeId(modeId);
					}
					else if(status_msg_handle.equals("03"))
					{
						if(null != business)
						{
							try 
							{
								YwBusinessExtras ywBusinessExtras = new YwBusinessExtras();
								ywBusinessExtras.setBusiId(busiId);
								ywBusinessExtras.setCodeExtras(BusinessExtrasCodeType.ADD_GPS.getCode());
								ywBusinessExtras.setTypeExtras(BusinessExtrasType.AUDIT.getCode());
								ywBusinessExtras.setDpStatus(1);
								ywBusinessExtras = ywBusinessExtrasMapper.selectRefined(ywBusinessExtras);
								String gpsNum = "0";
								if(null != ywBusinessExtras)
								{
									gpsNum = ywBusinessExtras.getValueExtras();
								}
								ywBusinessExtras = new YwBusinessExtras();
								ywBusinessExtras.setBusiId(busiId);
								ywBusinessExtras.setCodeExtras(BusinessExtrasCodeType.ADD_GEPOSIT.getCode());
								ywBusinessExtras.setTypeExtras(BusinessExtrasType.AUDIT.getCode());
								ywBusinessExtras.setDpStatus(1);
								ywBusinessExtras = ywBusinessExtrasMapper.selectRefined(ywBusinessExtras);
								String jine = "0";
								if(null != ywBusinessExtras)
								{
									jine = ywBusinessExtras.getValueExtras();
								}
								ywBusinessExtras = new YwBusinessExtras();
								ywBusinessExtras.setBusiId(busiId);
								ywBusinessExtras.setCodeExtras(BusinessExtrasCodeType.FLEXIBLECHARGE.getCode());
								ywBusinessExtras.setTypeExtras(BusinessExtrasType.AUDIT.getCode());
								ywBusinessExtras.setDpStatus(1);
								ywBusinessExtras = ywBusinessExtrasMapper.selectRefined(ywBusinessExtras);
								String sfbt = "0";
								if(null != ywBusinessExtras)
								{
									sfbt = ywBusinessExtras.getValueExtras();
								}
								ywBusinessExtras = new YwBusinessExtras();
								ywBusinessExtras.setBusiId(busiId);
								ywBusinessExtras.setCodeExtras(BusinessExtrasCodeType.IS_SPECIAL_ORDER.getCode());
								ywBusinessExtras.setTypeExtras(BusinessExtrasType.AUDIT.getCode());
								ywBusinessExtras.setDpStatus(1);
								ywBusinessExtras = ywBusinessExtrasMapper.selectRefined(ywBusinessExtras);
								String tsdd = "0";
								if(null != ywBusinessExtras)
								{
									tsdd = ywBusinessExtras.getValueExtras();
								}
								tsdd = "0".equals(tsdd) ? "否":"是";
								String titleInbox_ = "客户<"+cusName+">的风控过审附加条件有更新，请去收件箱查看详情";
								String content_ = "客户：<"+cusName+"><br/>";
								content_ += "附加条件：征信加收押金<"+jine+">元<br/>";
								content_ += "加装GPS<"+gpsNum+">个<br/>";
								content_ += "收费变通<"+ sfbt + ">元<br/>";
								content_ += "延迟收款<"+ tsdd + "><br/>";
								content_ += "经办人：<" + currentUserName + "><br/>";
								content_ += "经办时间：<" + nowString + "><br/>";
								otherInbox.setTitleInbox(titleInbox_);
								otherInbox.setContentInbox(content_);
								otherInbox.setDateInbox(now);
								otherInbox.setStatusInbox(1);
								otherInbox.setDateFirstRead(now);
								otherInboxMapper.insert(otherInbox);
							} 
							catch (Exception e) 
							{
								
								logger.error(e.getMessage());
							}
							
							sqlXmls = "select t.id,t.`name`,t.`value` from dp_base_data_dictionary t where t.parent_value = 'Inbox_Finance'";
							List<Map<String, String>> result1 = publicDao.queryWhereSql(sqlXmls);
							if(null != result1 && result1.size() > 0)
							{
								for(int x=0;x<result1.size();x++)
								{
									try 
									{
										otherInbox.initInsertData(currentUserId, currentUserName);
										content = "";
										Map<String, String> map = result1.get(x);
										String titleInbox = "<"+business.getOperatorName()+">修改了<"+cusName+">的征信附加信息";
										otherInbox.setTitleInbox(titleInbox);
										content += "事件：征信附加信息有修改，可进入客户按揭日报表查看详情/n";
										content += "经办人：<"+business.getOperatorName()+">/n";
										content += "经办时间：<"+nowString+">/n";
										otherInbox.setContentInbox(content);
										otherInbox.setDateInbox(now);
										otherInbox.setStatusInbox(1);
										otherInbox.setDateFirstRead(now);
										otherInbox.setReceiverId(map.get("value"));
										otherInboxMapper.insert(otherInbox);
									} 
									catch (Exception e) 
									{
										
										logger.error(e.getMessage());
									}
								}
							}
							
							sqlXmls = "select t.id,t.`name`,t.`value` from dp_base_data_dictionary t where t.parent_value = 'Inbox_Checker'";
							result1 = publicDao.queryWhereSql(sqlXmls);
							if(null != result1 && result1.size() > 0)
							{                                    
								for(int x=0;x<result1.size();x++)
								{
								
									try 
									{
										otherInbox.initInsertData(currentUserId, currentUserName);
										content = "";
										Map<String, String> map = result1.get(x);
										String titleInbox = "<"+business.getOperatorName()+">修改了<"+cusName+">的征信附加信息";
										otherInbox.setTitleInbox(titleInbox);
										content += "事件：征信附加信息有修改，可进入客户按揭日报表查看详情/n";
										content += "经办人：<"+business.getOperatorName()+">/n";
										content += "经办时间：<"+nowString+">/n";
										otherInbox.setContentInbox(content);
										otherInbox.setDateInbox(now);
										otherInbox.setStatusInbox(1);
										otherInbox.setDateFirstRead(now);
										otherInbox.setReceiverId(map.get("value"));
										otherInboxMapper.insert(otherInbox);
									} 
									catch (Exception e)
									{
										
										logger.error(e.getMessage());
									}
								}
							}
						}
					}
				}
			}
		} 
		//电审一审结果
		else if(typeMsgEvent.equals("06"))
		{
			
		}
		//电审二审结果
		else if(typeMsgEvent.equals("07"))
		{
			
		}
		//资审一审结果
		else if(typeMsgEvent.equals("08"))
		{
			
		}
		//资审二审结果
		else if(typeMsgEvent.equals("09"))
		{
			
		}
		//风控经理审核结果
		else if(typeMsgEvent.equals("10"))
		{
			
		}
		//申请垫资提醒
		else if(typeMsgEvent.equals("12"))
		{
		}
		//申请垫资预警
		else if(typeMsgEvent.equals("13"))
		{
		}
		//订单退回资审
		else if(typeMsgEvent.equals("14"))
		{
		}
		//资料补齐补审
		else if(typeMsgEvent.equals("15"))
		{
		}
		//绿色通道补审结果
		else if(typeMsgEvent.equals("16"))
		{
		}
		//过户补审结果
		else if(typeMsgEvent.equals("17"))
		{
		}
		//通融审核结果
		else if(typeMsgEvent.equals("18"))
		{
		}
		//大额垫款审批结果
		else if(typeMsgEvent.equals("19"))
		{
		}
		//财务打款通知
		else if(typeMsgEvent.equals("20"))
		{
			DhInsteadPaymentApply dhInsteadPaymentApply= new DhInsteadPaymentApply();
			dhInsteadPaymentApply.setBusiId(busiId);;
			dhInsteadPaymentApply=dhInsteadPaymentApplyMapper.selectRefined(dhInsteadPaymentApply);
			String customerName=dhInsteadPaymentApply.getCusName();
	        otherMessageApp.setModeId(ModeIDType.CWDK.getCode());
	        otherMessageApp.setBusiId(dhInsteadPaymentApply.getBusiId());
	        otherMessageApp.setDataid(dhInsteadPaymentApply.getId());
	        otherMessageApp.setTypeMsg("01");
	        otherMessageApp.setTypeMsgEvent("20");
	        otherMessageApp.setNotificationBar("<"+customerName+">的订单,财务已打款");
	        otherMessageApp.setTitle("<"+customerName+">的订单,财务已打款,");
	        content="通知：<"+customerName+"> 的订单,财务已打款"+
							"打款银行：<"+dhInsteadPaymentApply.getLoanBank()+">"+
							"财务审核人：<"+dhInsteadPaymentApply.getAuditor()+">"+
							"财务审核时间：<"+dhInsteadPaymentApply.getTimeAudit()+">";
	        otherMessageApp.setContent(content);
	        otherMessageApp.setTimeSend(new Date());
	        String shortMessage="客户<"+customerName+">的订单，财务已打款，请及早提车上牌";
	        otherShortMessage.setContent(shortMessage);
	        otherMessageApp.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
		}
		//提车+上牌
		else if("21".equals(typeMsgEvent)) {
			//事件处理配置
			for(int i=0;i<result.size();i++) {
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				
				if("1".equals(value_msg_handle)) {
					if("01".equals(status_msg_handle)){
						content = "客户<" + cusName + ">的订单，财务已打款，请及早提车上牌";
						otherShortMessage.setContent(content);
						otherShortMessage.setTypeMsg("01"); //提醒
						otherShortMessage.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
					} else if("02".equals(status_msg_handle)) {
						notificationBar = "<" + cusName + ">的订单，请及早提车上牌";
						title = "<" + cusName + ">的订单，请及早提车上牌";
						content = "提示：<" + cusName + ">的订单，财务已打款，请及早提车上牌";
						
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setTypeMsg("01"); //提醒
						otherMessageApp.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
						
					} else if("03".equals(status_msg_handle)) {
						
					}
				}
			}
		} else if("22".equals(typeMsgEvent)) { //提车预警
			//查找提车预警
			OtherWantWarning otherWantWarning = new OtherWantWarning();
			otherWantWarning.setDpStatus(DpStatus.NORMAL.getCode());
			otherWantWarning.setBusiId(busiId);
			otherWantWarning.setStatusMsg(1);
			otherWantWarning.setModeId(ModeIDType.TC.getCode());
			otherWantWarning = otherWantWarningMapper.selectRefined(otherWantWarning);
			if(otherWantWarning == null) {
				return;
			}
			String otherWantWarningContent = otherWantWarning.getContent();
			
			JSONObject parseObject = JSON.parseObject(otherWantWarningContent);
			OtherMessageApp otherWantWarningMessageApp = parseObject.getObject("alertMsg", OtherMessageApp.class);
			
			//事件处理配置
			for(int i=0;i<result.size();i++) {
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				
				if("1".equals(value_msg_handle)) {
					if("01".equals(status_msg_handle)){
						otherShortMessage.setContent(parseObject.getString("shortMsg"));
						otherShortMessage.setTypeMsg("03"); //预警
						otherShortMessage.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
					} else if("02".equals(status_msg_handle)) {
						if(null == otherWantWarningMessageApp) {
							continue;
						}
						notificationBar = otherWantWarningMessageApp.getNotificationBar();
						title = otherWantWarningMessageApp.getTitle();
						content = otherWantWarningMessageApp.getContent();
						
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setTypeMsg("03"); //预警
						otherMessageApp.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
						
					} else if("03".equals(status_msg_handle)) {
						
					}
				}
			}
		}
		//上牌预警
		else if("23".equals(typeMsgEvent))
		{
			
			//提车预警
			//查找提车预警
			OtherWantWarning otherWantWarning = new OtherWantWarning();
			otherWantWarning.setDpStatus(DpStatus.NORMAL.getCode());
			otherWantWarning.setBusiId(busiId);
			otherWantWarning.setStatusMsg(1);
			otherWantWarning.setModeId(ModeIDType.SP.getCode());
			otherWantWarning = otherWantWarningMapper.selectRefined(otherWantWarning);
			if(otherWantWarning == null) {
				return;
			}
			String otherWantWarningContent = otherWantWarning.getContent();
			
			JSONObject parseObject = JSON.parseObject(otherWantWarningContent);
			OtherMessageApp otherWantWarningMessageApp = parseObject.getObject("alertMsg", OtherMessageApp.class);
			
			//事件处理配置
			for(int i=0;i<result.size();i++) {
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				
				if("1".equals(value_msg_handle)) {
					if("01".equals(status_msg_handle)){
						otherShortMessage.setContent(parseObject.getString("shortMsg"));
						otherShortMessage.setTypeMsg("03"); //预警
						otherShortMessage.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
					} else if("02".equals(status_msg_handle)) {
						if(null == otherWantWarningMessageApp) {
							continue;
						}
						notificationBar = otherWantWarningMessageApp.getNotificationBar();
						title = otherWantWarningMessageApp.getTitle();
						content = otherWantWarningMessageApp.getContent();
						
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setTypeMsg("03"); //预警
						otherMessageApp.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
						
					} else if("03".equals(status_msg_handle)) {
						
					}
				}
			}
		}
		//抵押
		else if("24".equals(typeMsgEvent)) {
			//事件处理配置
			for(int i=0;i<result.size();i++) {
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				
				if("1".equals(value_msg_handle)) {
					if("01".equals(status_msg_handle)){
						content = "提示：客户<" + cusName + ">的订单，请及早办理抵押";
						otherShortMessage.setContent(content);
						otherShortMessage.setTypeMsg("01"); //提醒
						otherShortMessage.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
					} else if("02".equals(status_msg_handle)) {
						notificationBar = "客户<" + cusName + ">的订单，请及早办理抵押";
						title = "客户<" + cusName + ">的订单，请及早办理抵押";
						content = "提示：客户<" + cusName + ">的订单，请及早办理抵押";
						
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setTypeMsg("01"); //提醒
						otherMessageApp.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
						
					} else if("03".equals(status_msg_handle)) {
						
					}
				}
			}
		} else if("25".equals(typeMsgEvent)) { //抵押预警
			//查找抵押预警
			OtherWantWarning otherWantWarning = new OtherWantWarning();
			otherWantWarning.setDpStatus(DpStatus.NORMAL.getCode());
			otherWantWarning.setBusiId(busiId);
			otherWantWarning.setStatusMsg(1);
			otherWantWarning.setModeId(ModeIDType.DY.getCode());
			otherWantWarning = otherWantWarningMapper.selectRefined(otherWantWarning);
			if(otherWantWarning == null) {
				return;
			}
			String otherWantWarningContent = otherWantWarning.getContent();
			
			JSONObject parseObject = JSON.parseObject(otherWantWarningContent);
			OtherMessageApp otherWantWarningMessageApp = parseObject.getObject("alertMsg", OtherMessageApp.class);
			
			//事件处理配置
			for(int i=0;i<result.size();i++) {
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				
				if("1".equals(value_msg_handle)) {
					if("01".equals(status_msg_handle)){
						otherShortMessage.setContent(parseObject.getString("shortMsg"));
						otherShortMessage.setTypeMsg("03"); //预警
						otherShortMessage.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
					} else if("02".equals(status_msg_handle)) {
						if(null == otherWantWarningMessageApp) {
							continue;
						}
						notificationBar = otherWantWarningMessageApp.getNotificationBar();
						title = otherWantWarningMessageApp.getTitle();
						content = otherWantWarningMessageApp.getContent();
						
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setTypeMsg("03"); //预警
						otherMessageApp.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
						
					} else if("03".equals(status_msg_handle)) {
						
					}
				}
			}
		}
		
		//鑫合汇初审结果提示  //鑫合汇终审结果提示 //鑫合汇风险审核结果提醒
		else if("28".equals(typeMsgEvent) || "29".equals(typeMsgEvent) || "30".equals(typeMsgEvent)) 
		{ 
			ThAuditinfo thAuditinfo = new ThAuditinfo();
			thAuditinfo.setDpStatus(DpStatus.NORMAL.getCode());
			thAuditinfo.setBusiId(busiId);
			thAuditinfo.setThirdModeId(modeId);
			thAuditinfo = thAuditinfoMapper.selectRefined(thAuditinfo);
			String approveStatusName = "";
			if(null != thAuditinfo) {
				approveStatusName = thAuditinfo.getApproveStatusName();
			}
			
			if(StringUtils.isBlank(approveStatusName)) {
				approveStatusName = "暂时没有网络征信结果";
			}
			
			//事件处理配置
			for(int i=0; i < result.size(); i++) {
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				
				if("1".equals(value_msg_handle)) {
					if("01".equals(status_msg_handle)){
						content = "客户<" + cusName + ">鑫合汇征信查询结果：" + approveStatusName + "，详情请登录APP查看。";
						otherShortMessage.setContent(content);
						otherShortMessage.setTypeMsg("01"); //提醒
						otherShortMessage.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
					} else if("02".equals(status_msg_handle)) {
						notificationBar = "客户<" + cusName + ">鑫合汇征信查询结果:" + approveStatusName;
						title = "客户<" + cusName + ">鑫合汇征信查询结果";
						content = "反馈时间：" + nowString + "/n征信结果：" + approveStatusName;
						
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setTypeMsg("01"); //提醒
						otherMessageApp.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
						
					} else if("03".equals(status_msg_handle)) {
						
					}
				}
			}
		} else if("31".equals(typeMsgEvent)) { //修改购车人
			//事件处理配置
			for(int i=0;i<result.size();i++) {
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				
				if("1".equals(value_msg_handle)) {
					if("01".equals(status_msg_handle)){
						content = "<" + currentUserName + ">修改了购车人信息";
						otherShortMessage.setContent(content);
						otherShortMessage.setTypeMsg("02"); //通知
						otherShortMessage.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
					} else if("02".equals(status_msg_handle)) {
						notificationBar = "<" + currentUserName + ">修改了购车人信息";
						title = "<" + currentUserName + ">修改了购车人信息";
						content = "事件：客户<"+cusName+">的信息被修改，可进入客户订单查看详情/n"
								+ "经办人：<" + currentUserName + ">/n"
								+ "经办时间：<" + nowString + ">/n";
						
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setTypeMsg("02"); //通知
						otherMessageApp.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
						
					} else if("03".equals(status_msg_handle)) {
						List<OtherInbox> otherInboxs = CollectionInitUtil.emptyList();
						FkAuditListExt fkAuditListExt = new FkAuditListExt();
						fkAuditListExt.setBusiId(busiId);
						fkAuditListExt.setStatusList(1);
						fkAuditListExt.setBaseWhere();
						fkAuditListExt.withOutPage();
						List<FkAuditList> fkAuditLists = fkAuditListMapper.selectByExt(fkAuditListExt);
						if(CollectionUtils.isNotEmpty(fkAuditLists)) {
							Set<String> operatorIds = CollectionInitUtil.emptySet();
							for(FkAuditList fkAuditList : fkAuditLists) {
								String operatorId = fkAuditList.getOperatorId();
								if(StringUtils.isNotBlank(operatorId) && !operatorIds.contains(operatorId)) {
									operatorIds.add(operatorId);
									//发送站内容
									OtherInbox otherInbox_ = new OtherInbox();
									otherInbox_.initInsertData(currentUserId, currentUserName);
									otherInbox_.setBusiId(busiId);
									otherInbox_.setModeId(modeId);
									otherInbox_.setTypeMsgEvent(typeMsgEvent);
									otherInbox_.setReceiverId(operatorId);
									otherInbox_.setTitleInbox("<" + currentUserName + ">修改了购车人信息");
									String inboxContent = "事件：客户<"+cusName+">的信息被修改，可进入客户订单查看详情<br/>"
											+ "经办人：<" + currentUserName + "><br/>"
											+ "经办时间：<" + nowString + "><br/>";
									otherInbox_.setContentInbox(inboxContent);
									otherInbox_.setDateInbox(now);
									otherInbox_.setStatusInbox(1);
									otherInboxs.add(otherInbox_);
								}
							}
						}
						if(CollectionUtils.isNotEmpty(otherInboxs)) {
							otherInboxMapper.insertBatch(otherInboxs);
						}
					}
				}
			}
		} else if("32".equals(typeMsgEvent)) { //更换配偶
			//事件处理配置
			for(int i=0;i<result.size();i++) {
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				
				if("1".equals(value_msg_handle)) {
					if("01".equals(status_msg_handle)){
						content = "<" + currentUserName + ">操作了订单变更主借人，<" + moreParam[1] + ">变更为<" + moreParam[0] + ">";
						otherShortMessage.setContent(content);
						otherShortMessage.setTypeMsg("02"); //通知
						otherShortMessage.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
					} else if("02".equals(status_msg_handle)) {
						notificationBar = "<" + currentUserName + ">操作了订单变更主借人，<" + moreParam[1] + ">变更为<" + moreParam[0] + ">";
						title = "<" + currentUserName + ">操作了订单变更主借人，<" + moreParam[1] + ">变更为<" + moreParam[0] + ">";
						content = "事件：订单变更主借人成功，<" + moreParam[1] + ">变更为<" + moreParam[0] + ">，请注意完善资料/n"
								+ "经办人：<" + currentUserName + ">/n"
								+ "经办时间：<" + nowString + ">/n";
						
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setTypeMsg("02"); //通知
						otherMessageApp.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
						
					} else if("03".equals(status_msg_handle)) {
						/*moreParam 0 新客户 1 老客户*/
						otherInbox.setTitleInbox("<" + currentUserName + ">操作了订单变更主借人");
						String inboxContent = "事件：订单变更主借人成功，<" + moreParam[1] + ">变更为<" + moreParam[0] + ">，请注意完善资料<br/>"
								+ "经办人：<" + currentUserName + "><br/>"
								+ "经办时间：<" + nowString + "><br/>";
						otherInbox.setContentInbox(inboxContent);
						otherInbox.setDateInbox(now);
						otherInbox.setStatusInbox(1);
						int count = otherInboxMapper.insert(otherInbox);
						if(count < 1)
						{
							throw new BaseException("otherInboxMapper insert error",ResultFlagType.FAIL.getCode().toString());
						}
					}
				}
			}	
			
//			发短信	01
//			发送APP推送	02
//			发送站内信	03

		} else if("33".equals(typeMsgEvent)) { //资审一审
			//事件处理配置 绿色通道订单-财务已垫款
			String salesmanName = business.getSalesmanName();
			String orgName = null;
			String priOrgName = null;
			if(StringUtils.isNotBlank(salesmanId)) {
				BaseSalersman baseSalersman = baseSalersmanMapper.selectByPrimaryKey(salesmanId);
				if(null != baseSalersman) {
					if(StringUtils.isBlank(salesmanName)) {
						salesmanName = baseSalersman.getName();
					}
					String unitId = baseSalersman.getUnitId();
					if(StringUtils.isNotBlank(unitId)) {
						BaseBusiUnit baseBusiUnit = baseBusiUnitMapper.selectByPrimaryKey(unitId);
						if(null != baseBusiUnit) {
							orgName = baseBusiUnit.getOrgName();
							String orgCode = baseBusiUnit.getOrgCode();
							if(StringUtils.isNotBlank(orgCode)) {
								if(orgCode.length() > 4) {
									String priOrgCode = orgCode.substring(0, 4);
									BaseBusiUnit baseBusiUnit_ = new BaseBusiUnit();
									baseBusiUnit_.setDpStatus(DpStatus.NORMAL.getCode());
									baseBusiUnit_.setOrgCode(priOrgCode);
									baseBusiUnit_ = baseBusiUnitMapper.selectRefined(baseBusiUnit_);
									if(null != baseBusiUnit_) {
										priOrgName = baseBusiUnit_.getOrgName();
									}
								} else {
									priOrgName = orgName;
								}
							}
						}
					}
					
				}
			}
			for(int i=0;i<result.size();i++) {
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				if("1".equals(value_msg_handle)) {
					if("01".equals(status_msg_handle)){
						content = "<" + salesmanName + ">的客户<" + cusName + ">,绿色通道订单财务已垫款";
						otherShortMessage.setContent(content);
						otherShortMessage.setTypeMsg("02"); //通知
						otherShortMessage.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
					} else if("02".equals(status_msg_handle)) {
						notificationBar = "<" + salesmanName + ">的客户<" + cusName + ">,绿色通道订单财务已垫款";
						title = "<" + salesmanName + ">的客户<" + cusName + ">,绿色通道订单财务已垫款";
						content = "事件：绿色通道订单财务已垫款/n"
								+ "客户：<" + cusName + ">/n"
//								<省公司>-<分部门>-<业务员>
								+ "业务员：<" +  priOrgName + ">-<" +  orgName + ">-<" + salesmanName + ">/n"
								+ "经办人：<" + currentUserName + ">/n"
								+ "经办时间：<" + nowString + ">/n";
						
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setTypeMsg("02"); //通知
						otherMessageApp.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
						
					} else if("03".equals(status_msg_handle)) {
						if(ArrayUtils.isNotEmpty(moreParam)) {
							String[] receiverIds = moreParam[0].split(",");
							for(String receiverId_ : receiverIds) {
								if(StringUtils.isBlank(receiverId_)) {
									continue;
								}
								otherInbox.initInsertData(currentUserId, currentUserName);
								otherInbox.setTitleInbox("<" + salesmanName + ">的客户<" + cusName + ">,绿色通道订单财务已垫款");
								String inboxContent = "事件：绿色通道订单财务已垫款<br/>"
										+ "客户：<" + cusName + "><br/>"
//								<省公司>-<分部门>-<业务员>
										+ "业务员：<" +  priOrgName + ">-<" +  orgName + ">-<" + salesmanName + "><br/>"
										+ "经办人：<" + currentUserName + "><br/>"
										+ "经办时间：<" + nowString + "><br/>";
								otherInbox.setContentInbox(inboxContent);
								otherInbox.setDateInbox(now);
								otherInbox.setStatusInbox(1);
								otherInbox.setReceiverId(receiverId_);
								otherInboxMapper.insert(otherInbox);
							}
						}
					}
				}
			}	
		} 
		else if("34".equals(typeMsgEvent)) { //后补资料
			//事件处理配置 后补资料
			for(int i=0;i<result.size();i++) {
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				if("1".equals(value_msg_handle)) {
						String salesmanName = business.getSalesmanName();
						if(StringUtils.isBlank(salesmanName)) {
							BaseSalersman baseSalersman = baseSalersmanMapper.selectByPrimaryKey(salesmanId);
							salesmanName = baseSalersman.getName();
						}
						if("01".equals(status_msg_handle)){
							content = "<" + salesmanName + ">的客户<" + cusName + ">增加了后补资料。";
							otherShortMessage.setContent(content);
							otherShortMessage.setTypeMsg("02"); //通知
							otherShortMessage.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
						} else if("02".equals(status_msg_handle)) {
							notificationBar = "<" + salesmanName + ">的客户<" + cusName + ">增加了后补资料。";
							title = "<" + salesmanName + ">的客户<" + cusName + ">增加了后补资料。";
							content = "事件：增加了后补资料/n"
									+ "客户：<" + cusName + ">/n"
									+ "备注：<" + moreParam[1] + ">/n"
									+ "业务员：<" + salesmanName + ">/n"
									+ "经办人：<" + currentUserName + ">/n"
									+ "经办时间：<" + nowString + ">/n";
							
							otherMessageApp.setNotificationBar(notificationBar);
							otherMessageApp.setTitle(title);
							otherMessageApp.setContent(content);
							otherMessageApp.setTypeMsg("02"); //通知
							otherMessageApp.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
							
						} else if("03".equals(status_msg_handle)) {
							if(ArrayUtils.isNotEmpty(moreParam)) {
								String[] receiverIds = moreParam[0].split(",");
								for(String receiverId_ : receiverIds) {
									if(StringUtils.isBlank(receiverId_)) {
										continue;
									}
									otherInbox.initInsertData(currentUserId, currentUserName);
									otherInbox.setTitleInbox("<" + salesmanName + ">的客户<" + cusName + ">增加了后补资料。");
									String inboxContent = "事件：增加了后补资料<br/>"
											+ "客户：<" + cusName + "><br/>"
											+ "业务员：<" + salesmanName + "><br/>"
											+ "备注：<" + moreParam[1] + "><br/>"
											+ "经办人：<" + currentUserName + "><br/>"
											+ "经办时间：<" + nowString + "><br/>";
									otherInbox.setContentInbox(inboxContent);
									otherInbox.setDateInbox(now);
									otherInbox.setStatusInbox(1);
									otherInbox.setReceiverId(receiverId_);
									otherInboxMapper.insert(otherInbox);
								}
							}
						}
					}
				}
			}
			
		else if("35".equals(typeMsgEvent)) { //修改贷款审核一
			//事件处理配置 修改贷款审核一
			//审核通过时，如果不需要审核二，那么给业务员推送app信息；如果需要审核二，那么给特定人员（数据字典 Edit_Loan_SHOne_Inform）发送站内信。
			String auditResult = "1".equals(moreParam[0]) ? "通过" : "不通过";
			//是否给特定人员发信
			boolean teDingRenYuan = "1".equals(moreParam[1]) ? true : false;
			String salesmanName = business.getSalesmanName();
			String orgName = null;
			String priOrgName = null;
			if(StringUtils.isNotBlank(salesmanId)) {
				BaseSalersman baseSalersman = baseSalersmanMapper.selectByPrimaryKey(salesmanId);
				if(null != baseSalersman) {
					if(StringUtils.isBlank(salesmanName)) {
						salesmanName = baseSalersman.getName();
					}
					String unitId = baseSalersman.getUnitId();
					if(StringUtils.isNotBlank(unitId)) {
						BaseBusiUnit baseBusiUnit = baseBusiUnitMapper.selectByPrimaryKey(unitId);
						if(null != baseBusiUnit) {
							orgName = baseBusiUnit.getOrgName();
							String orgCode = baseBusiUnit.getOrgCode();
							if(StringUtils.isNotBlank(orgCode)) {
								if(orgCode.length() > 4) {
									String priOrgCode = orgCode.substring(0, 4);
									BaseBusiUnit baseBusiUnit_ = new BaseBusiUnit();
									baseBusiUnit_.setDpStatus(DpStatus.NORMAL.getCode());
									baseBusiUnit_.setOrgCode(priOrgCode);
									baseBusiUnit_ = baseBusiUnitMapper.selectRefined(baseBusiUnit_);
									if(null != baseBusiUnit_) {
										priOrgName = baseBusiUnit_.getOrgName();
									}
								} else {
									priOrgName = orgName;
								}
							}
						}
					}
					
				}
			}

			for(int i=0;i<result.size();i++) {
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				if("1".equals(value_msg_handle)) { //启用
						if("01".equals(status_msg_handle)){ //短信
							content = "<" + salesmanName + ">的客户 <" + cusName + ">申请修改贷款信息，审核一<" + auditResult + ">";
							otherShortMessage.setContent(content);
							otherShortMessage.setTypeMsg("02"); //通知
							otherShortMessage.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
						} else if("02".equals(status_msg_handle)) { //app消息
							if(!teDingRenYuan) {
								notificationBar = "<" + salesmanName + ">的客户 <" + cusName + ">申请修改贷款信息，审核一<" + auditResult + ">";
								title = "<" + salesmanName + ">的客户 <" + cusName + ">申请修改贷款信息，审核一<" + auditResult + ">";
								content = "事件：修改贷款信息-审核1" + auditResult + "/n"
										+ "客户：<" + cusName + ">/n"
										+ "业务员：<" +  priOrgName + ">-<" +  orgName + ">-<" + salesmanName + ">/n"
										+ "经办人：<" + currentUserName + ">/n"
										+ "经办时间：<" + nowString + ">/n";
								otherMessageApp.setNotificationBar(notificationBar);
								otherMessageApp.setTitle(title);
								otherMessageApp.setContent(content);
								otherMessageApp.setTypeMsg("02"); //通知
								otherMessageApp.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
							}
						} else if("03".equals(status_msg_handle)) { //站内信
							if(teDingRenYuan) {
								List<SimpleDataDictionary> simpleDataDictionarys = cachedDictionaryService.getCachedDataDics(DataDicType.EDIT_LOAN_SHONE_INFORM);
								List<String> receiverIds = simpleDataDictionarys.stream().map(item -> item.getValue()).filter(item -> StringUtils.isNotBlank(item)).collect(Collectors.toList());
								for(String receiverId_ : receiverIds) {
									if(StringUtils.isBlank(receiverId_)) {
										continue;
									}
									otherInbox.initInsertData(currentUserId, currentUserName);
									otherInbox.setTitleInbox("<" + salesmanName + ">的客户 <" + cusName + ">申请修改贷款信息，审核一<" + auditResult + ">");
									String inboxContent = "事件：修改贷款信息-审核1" + auditResult + "<br/>"
											+ "客户：<" + cusName + "><br/>"
											+ "业务员：<" +  priOrgName + ">-<" +  orgName + ">-<" + salesmanName + "><br/>"
											+ "经办人：<" + currentUserName + "><br/>"
											+ "经办时间：<" + nowString + "><br/>";
									otherInbox.setContentInbox(inboxContent);
									otherInbox.setDateInbox(now);
									otherInbox.setStatusInbox(1);
									otherInbox.setReceiverId(receiverId_);
									otherInboxMapper.insert(otherInbox);
								}
							}
						}
					}
				}
			}	
		else if("36".equals(typeMsgEvent)) { //审核二通过或者拒绝时，给业务员发推送app信息
			//审核二通过或者拒绝时，给业务员发推送app信息
			String auditResult = "1".equals(moreParam[0]) ? "通过" : "不通过";
			String salesmanName = business.getSalesmanName();
			String orgName = null;
			String priOrgName = null;
			if(StringUtils.isNotBlank(salesmanId)) {
				BaseSalersman baseSalersman = baseSalersmanMapper.selectByPrimaryKey(salesmanId);
				if(null != baseSalersman) {
					if(StringUtils.isBlank(salesmanName)) {
						salesmanName = baseSalersman.getName();
					}
					String unitId = baseSalersman.getUnitId();
					if(StringUtils.isNotBlank(unitId)) {
						BaseBusiUnit baseBusiUnit = baseBusiUnitMapper.selectByPrimaryKey(unitId);
						if(null != baseBusiUnit) {
							orgName = baseBusiUnit.getOrgName();
							String orgCode = baseBusiUnit.getOrgCode();
							if(StringUtils.isNotBlank(orgCode)) {
								if(orgCode.length() > 4) {
									String priOrgCode = orgCode.substring(0, 4);
									BaseBusiUnit baseBusiUnit_ = new BaseBusiUnit();
									baseBusiUnit_.setDpStatus(DpStatus.NORMAL.getCode());
									baseBusiUnit_.setOrgCode(priOrgCode);
									baseBusiUnit_ = baseBusiUnitMapper.selectRefined(baseBusiUnit_);
									if(null != baseBusiUnit_) {
										priOrgName = baseBusiUnit_.getOrgName();
									}
								} else {
									priOrgName = orgName;
								}
							}
						}
					}
					
				}
			}
			
			for(int i=0;i<result.size();i++) {
				Map<String, String> maps = result.get(i);
				String status_msg_handle = maps.get("status_msg_handle");
				String value_msg_handle = maps.get("value_msg_handle");
				if("1".equals(value_msg_handle)) { //启用
					if("01".equals(status_msg_handle)){ //短信
						content = "<" + salesmanName + ">的客户 <" + cusName + ">申请修改贷款信息，审核二<" + auditResult + ">";
						otherShortMessage.setContent(content);
						otherShortMessage.setTypeMsg("02"); //通知
						otherShortMessage.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
					} else if("02".equals(status_msg_handle)) { //app消息
						notificationBar = "<" + salesmanName + ">的客户 <" + cusName + ">申请修改贷款信息，审核二<" + auditResult + ">";
						title = "<" + salesmanName + ">的客户 <" + cusName + ">申请修改贷款信息，审核二<" + auditResult + ">";
						content = "事件：修改贷款信息-审核2" + auditResult + "/n"
								+ "客户：<" + cusName + ">/n"
								+ "业务员：<" +  priOrgName + ">-<" +  orgName + ">-<" + salesmanName + ">/n"
								+ "经办人：<" + currentUserName + ">/n"
								+ "经办时间：<" + nowString + ">/n";
						otherMessageApp.setNotificationBar(notificationBar);
						otherMessageApp.setTitle(title);
						otherMessageApp.setContent(content);
						otherMessageApp.setTypeMsg("02"); //通知
						otherMessageApp.setStatusMsg(MessageStatus.WEI_TUI_SONG.getCode());
					} else if("03".equals(status_msg_handle)) { //站内信
//						List<SimpleDataDictionary> simpleDataDictionarys = cachedDictionaryService.getCachedDataDics(DataDicType.EDIT_LOAN_SHONE_INFORM);
//						List<String> receiverIds = simpleDataDictionarys.stream().map(item -> item.getValue()).filter(item -> StringUtils.isNotBlank(item)).collect(Collectors.toList());
//						for(String receiverId_ : receiverIds) {
//							if(StringUtils.isBlank(receiverId_)) {
//								continue;
//							}
//							otherInbox.initInsertData(currentUserId, currentUserName);
//							otherInbox.setTitleInbox("<" + salesmanName + ">的客户 <" + cusName + ">申请修改贷款信息，审核一<" + auditResult + ">");
//							String inboxContent = "事件：修改贷款信息-审核1" + auditResult + "<br/>"
//									+ "客户：<" + cusName + "><br/>"
//									+ "业务员：<" +  priOrgName + ">-<" +  orgName + ">-<" + salesmanName + "><br/>"
//									+ "经办人：<" + currentUserName + "><br/>"
//									+ "经办时间：<" + nowString + "><br/>";
//							otherInbox.setContentInbox(inboxContent);
//							otherInbox.setDateInbox(now);
//							otherInbox.setStatusInbox(1);
//							otherInbox.setReceiverId(receiverId_);
//							otherInboxMapper.insert(otherInbox);
//						}
					}
				}
			}
		}	
		//申请修改贷款信息调整
		else if("37".equals(typeMsgEvent)){
			YwBusinessQueryRequest ywBusinessQueryRequest=new YwBusinessQueryRequest();
			ywBusinessQueryRequest.setBaseWhere();
			ywBusinessQueryRequest.setId(busiId);
			ywBusinessQueryRequest.setRows(1);
			SysUser currentUser1=(SysUser) currentUser;
			ywBusinessQueryRequest.setBankLoan(currentUser1.getLoanBank());
			ywBusinessQueryRequest.setCodeUnits(currentUser1.getCodeUnits());
		    ywBusinessQueryRequest.setNeedLimit(true);
		    ywBusinessQueryRequest.setModifyLoanHistory(true);
			List<YwBusiness> list=ywBusinessLoanEditMapper.selectMultiByExt(ywBusinessQueryRequest);
			String custName="";
			String salesName="";
			String orgName="";
			String sorgName="";
			if(list!=null && list.size()>0){
				YwBusiness ywBusiness=list.get(0);
				custName=ywBusiness.getCustomerName();
				salesName=ywBusiness.getSalesmanName();
				orgName=ywBusiness.getOrgName();
				String orgCode=ywBusiness.getOrgCode();
				otherMessageApp.setModeId(ModeIDType.SQXGDKXX.getCode());
				otherMessageApp.setBusiId(busiId);
				YwBusinessLoanEdit ywBusinessLoanEdit=new YwBusinessLoanEdit();
				ywBusinessLoanEdit.setBusiId(busiId);
				ywBusinessLoanEdit.setDpStatus(DpStatus.NORMAL.getCode());
				ywBusinessLoanEdit=ywBusinessLoanEditMapper.selectRefined(ywBusinessLoanEdit);
				if(ywBusinessLoanEdit!=null){
					if(StringUtils.isNotBlank(orgCode)){
						if(StringUtils.isNotBlank(orgCode)&& orgCode.length()>4){
							String sorgCode=orgCode.substring(0,orgCode.length()-3);
							BaseBusiUnit baseBusiUnit=new BaseBusiUnit();
							baseBusiUnit.setOrgCode(sorgCode);
							baseBusiUnit.setDpStatus(DpStatus.NORMAL.getCode());
							baseBusiUnit=baseBusiUnitMapper.selectRefined(baseBusiUnit);
							if(baseBusiUnit!=null){
								sorgName=baseBusiUnit.getOrgName();
							}
						}
						
					}
					OtherInbox otherInbox_ = null;
					List<SimpleDataDictionary> simpleDataDictionarys = cachedDictionaryService.getCachedDataDics(DataDicType.APPLYEDITLOANINFORM);
					List<String> receiverIds = simpleDataDictionarys.stream().map(item -> item.getValue()).filter(item -> StringUtils.isNotBlank(item)).collect(Collectors.toList());
					for(String receiverId_ : receiverIds) {
						if(StringUtils.isBlank(receiverId_)) {
							continue;
						}
						otherInbox_ = new OtherInbox();
						otherInbox_.initInsertData(currentUserId, currentUserName);
						otherInbox_.setTitleInbox("<"+salesName+">的客户<"+custName+">申请修改贷款信息");
						content="事件：修改贷款信息-申请  "+
								"客户：<"+custName+">"+
								"业务员：<"+sorgName+">-<"+orgName+">-<"+salesName+">"+
								"经办人：<"+ywBusinessLoanEdit.getCreatorName()+">"+
								"经办时间：<"+ZhppDateUtil.stampToDate(ywBusinessLoanEdit.getCreated(), "yyyy-MM-dd")+">";
						otherInbox_.setContentInbox(content);
						otherInbox_.setDateInbox(now);
						otherInbox_.setStatusInbox(1);
						otherInbox_.setReceiverId(receiverId_);
						otherInbox_.setModeId(modeId);
						otherInbox_.setBusiId(busiId);
						otherInbox_.setTypeMsgEvent(typeMsgEvent);
						otherInboxMapper.insert(otherInbox_);
					}
				}
			}
		}
		//推送处理
		if(StringUtils.isNotBlank(otherMessageApp.getContent()))
		{
			//推送消息
			Set<String> alias = userMapSalermanHelper.getSalermanSysUserBySalesmanId(salesmanId);
			if(CollectionUtils.isNotEmpty(alias)) 
			{
				for(String alia : alias) 
				{
					SysUser sysUser = isysUserService.getLoginedUser(alia);
					if(null != sysUser)
					{
						if(StringUtils.isNotBlank(sysUser.getDeviceType()))
						{
							String devicetoken = sysUser.getDevicetoken();
							if(sysUser.getDeviceType().equals("ios"))
							{
								if(StringUtils.isNotBlank(devicetoken))
								{
									imei = devicetoken;
									typeApp = "ios";
									
									try 
									{
										JPushClient client = new JPushClient(PayloadBuild.appKeyIos, PayloadBuild.masterSecretIos);
										PushPayload payload = PayloadBuild.buildIOSPayload("",devicetoken,otherMessageApp.getNotificationBar());
										PushResult push = client.sendPush(payload);	
										if(push.getResponseCode() == 200)
										{
											typeMsg = "20";
											logger.debug("推送成功");
											statusMsg = 20;
										}
										else
										{
											logger.error("推送失败"+push.getResponseCode());
											typeMsg = "40";
											statusMsg = 40;
										}
										msgId = String.valueOf(push.msg_id);
									} 
									catch (Exception e) 
									{
										
										typeMsg = "40";
										statusMsg = 40;
									}
								}
							}
							else
							{
								if(StringUtils.isNotBlank(devicetoken))
								{
									imei = devicetoken;
									typeApp = "android";
									
									try 
									{
										JPushClient client = new JPushClient(PayloadBuild.masterSecretAndorid, PayloadBuild.appKeyAndorid);
										PushPayload payload = PayloadBuild.buildAndroidWinphonePayload("", devicetoken, otherMessageApp.getContent(),otherMessageApp.getNotificationBar());
										PushResult push = client.sendPush(payload);	
										if(push.getResponseCode() == 200)
										{
											statusMsg = 20;
											logger.debug("推送成功");
										}
										else
										{
											statusMsg = 40;
											logger.error("推送失败"+push.getResponseCode());
										}
										msgId = String.valueOf(push.msg_id);
									} 
									catch (Exception e) 
									{
										
										statusMsg = 40;
										logger.error(e.getMessage());
									}
								}
							}
						}
					}
				}
			}
			
			try 
			{
				otherMessageApp.setTypeApp(typeApp);
				otherMessageApp.setImei(imei);
				otherMessageApp.setStatusMsg(statusMsg);
				otherMessageApp.setMsgId(msgId);
				otherMessageAppMapper.insert(otherMessageApp);
			} 
			catch (Exception e)
			{
				
				logger.error(e.getMessage());
			}
		}
		
		//短信处理
		if(StringUtils.isNotBlank(otherShortMessage.getContent()))
		{
			try 
			{
				BaseAccountBusiUnit baseAccountBusiUnit = new BaseAccountBusiUnit();
				baseAccountBusiUnit.setIdUnit(salesmanId);
				baseAccountBusiUnit.notDeleted();
				BaseAccountBusiUnit dbBaseAccountBusiUnit = baseAccountBusiUnitMapper.selectRefined(baseAccountBusiUnit);
				if(dbBaseAccountBusiUnit != null && StringUtils.isNotBlank(dbBaseAccountBusiUnit.getUserId())) 
				{
					String userId = dbBaseAccountBusiUnit.getUserId();
					SysUser sysUser = sysUserMapper.selectByPrimaryKey(userId);
					if(StringUtils.isNotBlank(sysUser.getPhone()) && sysUser.getPhone().length() == 11)
					{
						appNewsService.diepuFaSongDuanXin(sysUser.getPhone(), "", otherShortMessage.getContent());
						statusMsg = 20;
						logger.debug("发送短信成功");
					}
				}
				otherShortMessage.setStatusMsg(statusMsg);
				otherShortMessageMapper.insert(otherShortMessage);
			}
			catch (Exception e) 
			{
				
				statusMsg = 40;
				logger.error(e.getMessage());
			}
		}
		return;
	}

	@Override
	public void diepuNewsHandleExtra(AbstractSysUser currentUser,String busiId) 
	{
		
		try 
		{
			//当前时间
			Date now = new Date();
			
			//短信
			OtherShortMessage otherShortMessage = new OtherShortMessage();
			if(null == currentUser)
			{
				otherShortMessage.initInsertData("00000000000000000000000000000000", "未登录用户");
			}
			else
			{
				otherShortMessage.initInsertData(currentUser.getId(),currentUser.getName());
			}
			otherShortMessage.setBusiId(busiId);
			otherShortMessage.setChannelSend("https://www.juhe.cn/");
			otherShortMessage.setTimeCreate(now);
			otherShortMessage.setTimeSend(now);
			otherShortMessage.setTypeMsg("1");
			
			
			//推送消息处理
			OtherMessageApp otherMessageApp = new OtherMessageApp();
			if(null == currentUser)
			{
				otherMessageApp.initInsertData("00000000000000000000000000000000", "未登录用户");
			}
			else
			{
				otherMessageApp.initInsertData(currentUser.getId(),currentUser.getName());
			}
			otherMessageApp.setBusiId(busiId);
			otherMessageApp.setChannelSend("https://www.jiguang.cn/");
			otherMessageApp.setTimeCreate(now);
			otherMessageApp.setTimeSend(now);
			
			
			YwBusiness business = ywBusinessMapper.selectByPrimaryKey(busiId);
			if(null != business)
			{
				String salesmanCode = business.getSalesmanCode();
				if(StringUtils.isNotBlank(salesmanCode))
				{
					BaseSalersman baseSalersman = new BaseSalersman();
					baseSalersman.setSalersmanCode(salesmanCode);
					baseSalersman.setDpStatus(1);
					baseSalersman = baseSalersmanMapper.selectRefined(baseSalersman);
					if(null != baseSalersman)
					{
						String unitCode = baseSalersman.getUnitCode();
						if(StringUtils.isNotBlank(unitCode))
						{
							String unitCodeSub = "";
							if(unitCode.length() > 4)
							{
								unitCodeSub = unitCode.substring(0,4);
							}
							
							String sqlXmls = "select t.id,t.code_unit,t.id_unit,t.user_id,t.type_msg_event,t.status_msg_handle from other_message_push_extra t where t.code_unit = '"+unitCode+"' and t.dp_status = 1";
							List<Map<String, String>> reuslt = publicDao.queryWhereSql(sqlXmls);
							if(null == reuslt || reuslt.size() < 1)
							{
								if(StringUtils.isNotBlank(unitCodeSub))
								{
									sqlXmls = "select t.id,t.code_unit,t.id_unit,t.user_id,t.type_msg_event,t.status_msg_handle from other_message_push_extra t where t.code_unit = '"+unitCodeSub+"' and t.dp_status = 1";
									reuslt = publicDao.queryWhereSql(sqlXmls);
								}
							}
							
							if(null != reuslt && reuslt.size() > 0)
							{
								for(int i=0;i<reuslt.size();i++)
								{
									Map<String, String>  maps = reuslt.get(i);
									String userId = maps.get("user_id");
									String statusMsgHandle = maps.get("status_msg_handle");
									
									String[] userIdArry = userId.split(",");
									if(null != userIdArry && userIdArry.length > 0)
									{
										String[] handle = statusMsgHandle.split(",");
										if(null != handle && handle.length > 0)
										{
											for(int x=0;x<handle.length;x++)
											{
												String msgEvent = maps.get("type_msg_event");
												
												//征信查询
												if(msgEvent.equals("03"))
												{
													if(handle[x].equals("01"))
													{
														for(int j=0;j<userIdArry.length;j++)
														{
															String uid = userIdArry[j];
															
															SysUser sysUser = sysUserMapper.selectByPrimaryKey(uid);
															if(null != sysUser)
															{
																otherShortMessage.setId(UUIDFactory.getUUID());
																otherShortMessage.setTypeMsgEvent("03");
																otherShortMessage.setTypeMsgEvent("03");
																String content = "<"+business.getCustomerName()+"> 征信查询结果：<通过>";
																otherShortMessage.setContent(content);
																otherShortMessageMapper.insert(otherShortMessage);
																appNewsService.diepuFaSongDuanXin(sysUser.getPhone(), "", content);
															}
														}
													}
													else if(handle[x].equals("02"))
													{
														for(int j=0;j<userIdArry.length;j++)
														{
															String uid = userIdArry[j];
															SysUser sysUser = sysUserMapper.selectByPrimaryKey(uid);
															if(null != sysUser)
															{
																String imei = "";
																String typeApp = "";
																int statusMsg = 0;
																String msgId = "";
																otherMessageApp.setId(UUIDFactory.getUUID());
																otherMessageApp.setSalesmanId(sysUser.getSalersmanId());
																otherMessageApp.setNotificationBar("<"+business.getCustomerName()+"> 征信查询结果：<通过>");
																otherMessageApp.setContent("<"+business.getCustomerName()+"> 征信查询结果：<通过>");
																if(StringUtils.isNotBlank(sysUser.getDeviceType()))
																{
																	String devicetoken = sysUser.getDevicetoken();
																	if(sysUser.getDeviceType().equals("ios"))
																	{
																		if(StringUtils.isNotBlank(devicetoken))
																		{
																			imei = devicetoken;
																			typeApp = "ios";
																			
																			try 
																			{
																				JPushClient client = new JPushClient(PayloadBuild.appKeyIos, PayloadBuild.masterSecretIos);
																				PushPayload payload = PayloadBuild.buildIOSPayload("",devicetoken,otherMessageApp.getNotificationBar());
																				PushResult push = client.sendPush(payload);	
																				if(push.getResponseCode() == 200)
																				{
																					logger.debug("推送成功");
																					statusMsg = 20;
																				}
																				else
																				{
																					logger.error("推送失败"+push.getResponseCode());
																					statusMsg = 40;
																				}
																				msgId = String.valueOf(push.msg_id);
																			} 
																			catch (Exception e) 
																			{
																				
																				statusMsg = 40;
																			}
																		}
																	}
																	else
																	{
																		if(StringUtils.isNotBlank(devicetoken))
																		{
																			imei = devicetoken;
																			typeApp = "android";
																			
																			try 
																			{
																				JPushClient client = new JPushClient(PayloadBuild.masterSecretAndorid, PayloadBuild.appKeyAndorid);
																				PushPayload payload = PayloadBuild.buildAndroidWinphonePayload("", devicetoken, otherMessageApp.getContent(),otherMessageApp.getNotificationBar());
																				PushResult push = client.sendPush(payload);	
																				if(push.getResponseCode() == 200)
																				{
																					statusMsg = 20;
																					logger.debug("推送成功");
																				}
																				else
																				{
																					statusMsg = 40;
																					logger.error("推送失败"+push.getResponseCode());
																				}
																				msgId = String.valueOf(push.msg_id);
																			} 
																			catch (Exception e) 
																			{
																				
																				statusMsg = 40;
																				logger.error(e.getMessage());
																			}
																		}
																	}
																}
																otherMessageApp.setTypeApp(typeApp);
																otherMessageApp.setImei(imei);
																otherMessageApp.setStatusMsg(statusMsg);
																otherMessageApp.setMsgId(msgId);
																otherMessageAppMapper.insert(otherMessageApp);
															}
														}
													}
													else if(handle[x].equals("03"))
													{
														
													}
												}
												//风控终审
												else if(msgEvent.equals("05"))
												{
													if(handle[x].equals("01"))
													{
														for(int j=0;j<userIdArry.length;j++)
														{
															String uid = userIdArry[j];
															
															SysUser sysUser = sysUserMapper.selectByPrimaryKey(uid);
															if(null != sysUser)
															{
																otherShortMessage.setId(UUIDFactory.getUUID());
																otherShortMessage.setTypeMsgEvent("05");
																otherShortMessage.setTypeMsgEvent("05");
																String content = "<"+business.getCustomerName()+"> 初审二审结果：<通过>";
																otherShortMessage.setContent(content);
																otherShortMessageMapper.insert(otherShortMessage);
																appNewsService.diepuFaSongDuanXin(sysUser.getPhone(), "", content);
															}
														}
													}
													else if(handle[x].equals("02"))
													{
														for(int j=0;j<userIdArry.length;j++)
														{
															String uid = userIdArry[j];
															SysUser sysUser = sysUserMapper.selectByPrimaryKey(uid);
															if(null != sysUser)
															{
																String imei = "";
																String typeApp = "";
																int statusMsg = 0;
																String msgId = "";
																otherMessageApp.setId(UUIDFactory.getUUID());
																otherMessageApp.setSalesmanId(sysUser.getSalersmanId());
																otherMessageApp.setNotificationBar("<"+business.getCustomerName()+"> 初审二审结果：<通过>");
																otherMessageApp.setContent("<"+business.getCustomerName()+"> 初审二审结果：<通过>");
																if(StringUtils.isNotBlank(sysUser.getDeviceType()))
																{
																	String devicetoken = sysUser.getDevicetoken();
																	if(sysUser.getDeviceType().equals("ios"))
																	{
																		if(StringUtils.isNotBlank(devicetoken))
																		{
																			imei = devicetoken;
																			typeApp = "ios";
																			
																			try 
																			{
																				JPushClient client = new JPushClient(PayloadBuild.appKeyIos, PayloadBuild.masterSecretIos);
																				PushPayload payload = PayloadBuild.buildIOSPayload("",devicetoken,otherMessageApp.getNotificationBar());
																				PushResult push = client.sendPush(payload);	
																				if(push.getResponseCode() == 200)
																				{
																					logger.debug("推送成功");
																					statusMsg = 20;
																				}
																				else
																				{
																					logger.error("推送失败"+push.getResponseCode());
																					statusMsg = 40;
																				}
																				msgId = String.valueOf(push.msg_id);
																			} 
																			catch (Exception e) 
																			{
																				
																				statusMsg = 40;
																			}
																		}
																	}
																	else
																	{
																		if(StringUtils.isNotBlank(devicetoken))
																		{
																			imei = devicetoken;
																			typeApp = "android";
																			
																			try 
																			{
																				JPushClient client = new JPushClient(PayloadBuild.masterSecretAndorid, PayloadBuild.appKeyAndorid);
																				PushPayload payload = PayloadBuild.buildAndroidWinphonePayload("", devicetoken, otherMessageApp.getContent(),otherMessageApp.getNotificationBar());
																				PushResult push = client.sendPush(payload);	
																				if(push.getResponseCode() == 200)
																				{
																					statusMsg = 20;
																					logger.debug("推送成功");
																				}
																				else
																				{
																					statusMsg = 40;
																					logger.error("推送失败"+push.getResponseCode());
																				}
																				msgId = String.valueOf(push.msg_id);
																			} 
																			catch (Exception e) 
																			{
																				
																				statusMsg = 40;
																				logger.error(e.getMessage());
																			}
																		}
																	}
																}
																otherMessageApp.setTypeApp(typeApp);
																otherMessageApp.setImei(imei);
																otherMessageApp.setStatusMsg(statusMsg);
																otherMessageApp.setMsgId(msgId);
																otherMessageAppMapper.insert(otherMessageApp);
															}
														}
													}
													else if(handle[x].equals("03"))
													{
														
													}
												}
												//风控总监审核
												else if(msgEvent.equals("11"))
												{
													if(handle[x].equals("01"))
													{
														for(int j=0;j<userIdArry.length;j++)
														{
															String uid = userIdArry[j];
															
															SysUser sysUser = sysUserMapper.selectByPrimaryKey(uid);
															if(null != sysUser)
															{
																otherShortMessage.setId(UUIDFactory.getUUID());
																otherShortMessage.setTypeMsgEvent("11");
																otherShortMessage.setTypeMsgEvent("11");
																String content = "<"+business.getCustomerName()+"> 风控总监结果：<通过>";
																otherShortMessage.setContent(content);
																otherShortMessageMapper.insert(otherShortMessage);
																appNewsService.diepuFaSongDuanXin(sysUser.getPhone(), "", content);
															}
														}
													}
													else if(handle[x].equals("02"))
													{
														for(int j=0;j<userIdArry.length;j++)
														{
															String uid = userIdArry[j];
															SysUser sysUser = sysUserMapper.selectByPrimaryKey(uid);
															if(null != sysUser)
															{
																String imei = "";
																String typeApp = "";
																int statusMsg = 0;
																String msgId = "";
																otherMessageApp.setId(UUIDFactory.getUUID());
																otherMessageApp.setSalesmanId(sysUser.getSalersmanId());
																otherMessageApp.setNotificationBar("<"+business.getCustomerName()+"> 风控总监结果：<通过>");
																otherMessageApp.setContent("<"+business.getCustomerName()+"> 风控总监结果：<通过>");
																if(StringUtils.isNotBlank(sysUser.getDeviceType()))
																{
																	String devicetoken = sysUser.getDevicetoken();
																	if(sysUser.getDeviceType().equals("ios"))
																	{
																		if(StringUtils.isNotBlank(devicetoken))
																		{
																			imei = devicetoken;
																			typeApp = "ios";
																			
																			try 
																			{
																				JPushClient client = new JPushClient(PayloadBuild.appKeyIos, PayloadBuild.masterSecretIos);
																				PushPayload payload = PayloadBuild.buildIOSPayload("",devicetoken,otherMessageApp.getNotificationBar());
																				PushResult push = client.sendPush(payload);	
																				if(push.getResponseCode() == 200)
																				{
																					logger.debug("推送成功");
																					statusMsg = 20;
																				}
																				else
																				{
																					logger.error("推送失败"+push.getResponseCode());
																					statusMsg = 40;
																				}
																				msgId = String.valueOf(push.msg_id);
																			} 
																			catch (Exception e) 
																			{
																				
																				statusMsg = 40;
																			}
																		}
																	}
																	else
																	{
																		if(StringUtils.isNotBlank(devicetoken))
																		{
																			imei = devicetoken;
																			typeApp = "android";
																			
																			try 
																			{
																				JPushClient client = new JPushClient(PayloadBuild.masterSecretAndorid, PayloadBuild.appKeyAndorid);
																				PushPayload payload = PayloadBuild.buildAndroidWinphonePayload("", devicetoken, otherMessageApp.getContent(),otherMessageApp.getNotificationBar());
																				PushResult push = client.sendPush(payload);	
																				if(push.getResponseCode() == 200)
																				{
																					statusMsg = 20;
																					logger.debug("推送成功");
																				}
																				else
																				{
																					statusMsg = 40;
																					logger.error("推送失败"+push.getResponseCode());
																				}
																				msgId = String.valueOf(push.msg_id);
																			} 
																			catch (Exception e) 
																			{
																				
																				statusMsg = 40;
																				logger.error(e.getMessage());
																			}
																		}
																	}
																}
																otherMessageApp.setTypeApp(typeApp);
																otherMessageApp.setImei(imei);
																otherMessageApp.setStatusMsg(statusMsg);
																otherMessageApp.setMsgId(msgId);
																otherMessageAppMapper.insert(otherMessageApp);
															}
														}
													}
													else if(handle[x].equals("03"))
													{
														
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		} 
		catch (Exception e)
		{
			
			logger.error(e.getMessage());
		}
		
	}
	
	public static void main(String[] args) {
		String unitCodeSub = "0013015";
		System.out.println(unitCodeSub.substring(0,unitCodeSub.length()-4));
	}
}
